Answer the question
In order to leave comments, you need to log in
How to display custom results in django?
There are three models:
# Модель мероприятия
class Event(models.Model):
title = models.CharField("Название мероприятия", max_length=25)
location = models.CharField("Место проведения", max_length=25)
# Модель простого поста в блоге
class Post(models.Model):
title = models.CharField("Заголовок поста", max_length=50)
body = models.TextField("Текст поста", blank=True, null=True)
pub_date = models.DateTimeField("Дата публикации", default=timezone.now)
# Модель поста привязанного к конкретному мероприятию
class EventPost(Post):
event = models.ForeignKey(Event, on_delete=models.CASCADE)
@property
def location(self):
location = Event.objects.get(pk=self.event)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question