Answer the question
In order to leave comments, you need to log in
How to write a model for django?
How to write a django model? About the task: There is a list of people, let's say 10 people. Every day you will need to mark each person with a conditional plus sign. Here's how I tried to do it:
class people(models.Model):
date = models.DateField("Дата")
a = models.CharField("Александр Иванов", max_length=1)
b = models.CharField("Алексей Иванов", max_length=1)
c = models.CharField("Даниил Иванов", max_length=1)
Answer the question
In order to leave comments, you need to log in
This is how your models should look like:
class People(models.Model):
first_name = models.CharField("Имя", max_length=64)
last_name = models.CharField("Фамилия", max_length=64)
def __str__(self):
return '{} {}'.format(self.first_name, self.last_name)
class PeoplePresence(models.Model):
date = models.DateField()
people = models.ManyToManyField(People)
def __str__(self):
return '{} {}'.format(self.date, self.people.__str__())
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question