{% for field in advert %}
{{ field.verbose_name }} => {{field.value}}
{% endfor %}
class Advert(models.Model):
class Meta:
verbose_name = 'Обьявление'
verbose_name_plural = 'Обьявления'
user = models.ForeignKey(User, on_delete=models.CASCADE, editable=False)
title = models.CharField(max_length=200, null=True, verbose_name="Заголовок")
purpose = models.ForeignKey(Purpose, on_delete=models.CASCADE, verbose_name="Тип реализаций")
property_type = models.ForeignKey(PropertyType, on_delete=models.SET_NULL, null=True, verbose_name="Категория")
price = models.BigIntegerField(verbose_name="Цена")
year_of_construction = models.PositiveSmallIntegerField(verbose_name="Год постройки", blank=True, null=True)
room = models.SmallIntegerField(blank=True, verbose_name="Количество комнат", null=True)
area = models.SmallIntegerField(blank=True, verbose_name="Площадь", null=True)
floor = models.SmallIntegerField(blank=True, verbose_name="Этаж", null=True)
floor_number = models.SmallIntegerField(blank=True, verbose_name="Этажность", null=True)
city = models.ForeignKey(City, on_delete=models.SET_NULL, verbose_name="Город", null=True)
street = models.CharField(max_length=100, verbose_name="Улица")
address = models.CharField(max_length=100, verbose_name="Адрес")
pledged = models.NullBooleanField(default=None, blank=True, verbose_name="В залоге")
create_date = models.DateTimeField(auto_now_add=True, verbose_name="Дата создания")
update_date = models.DateTimeField(auto_now=True, verbose_name="Дата редактирования")
active = models.BooleanField(default=True, verbose_name="Активно")
def __str__(self):
return "{} {} {} {}".format(self.pk, self.price, self.street, self.address)
class AdvertDetailView(DetailView):
model = Advert
template_name = "advert/_detail.html"
context_object_name = "advert"
Таблицы как создавать то при инициализации?