class Faculty(models.Model):
name = models.CharField(max_length=50, unique=True, null=True)
slug = models.SlugField(max_length=50, primary_key=True, unique=True)
dean_name = models.CharField(max_length=50, null=True, blank=True)
address = models.CharField(max_length=150, null=True, blank=True)
phone = models.CharField(max_length=50, null=True, blank=True)
email = models.EmailField(max_length=50, null=True, blank=True)
department_count = models.SmallIntegerField(null=True, default=0)
group_count = models.SmallIntegerField(null=True, default=0)
created_at = models.DateTimeField(auto_now_add=True, auto_now=False)
modified_at = models.DateTimeField(auto_now_add=False, auto_now=True)
def get_absolute_url(self):
return reverse('webnav:facultet', args=[self.slug])
def __str__(self):
return self.name
class Faculties(generic.ListView):
model = FacultyModel
context_object_name = 'faculties'
template_name = 'faculties.html'
{% for var in vars %}
<ul class="list-group m-l-1">
<li class="list-group-item infoList">
Имя: <span>{{ var.name|default:'Отсутствует' }}</span>
</li>
<li class="list-group-item infoList">
Адрес: <span>{{ var.addr|default:'Отсутствует' }}
</li>
<li class="list-group-item infoList">
Телефоны: <span>{{ var.tel|default:'Отсутствует' }}
</li>
<li class="list-group-item infoList">
e-mail: <span>{{ var.mail|default:'Отсутствует' }}
</li>
</ul>
{% endfor %}
{% for var in vars %}
<ul class="list-group m-l-1">
{% filter default:'None' %}
<li class="list-group-item infoList">
Имя: <span>{{ var.name }}</span>
</li>
<li class="list-group-item infoList">
Адрес: <span>{{ var.addr }}
</li>
<li class="list-group-item infoList">
Телефоны: <span>{{ var.tel }}
</li>
<li class="list-group-item infoList">
e-mail: <span>{{ var.mail }}
</li>
{% endfilter %}
</ul>
{% endfor %}