Answer the question
In order to leave comments, you need to log in
How to make a selection in django?
Django 1.8 has two models like this
class PassRoute(BaseRoute):
route_num = models.CharField(u"Номер маршрута", max_length=10, null=True, blank=True)
sum = models.DecimalField(u"Сумма", max_digits=10, decimal_places=2)
people = models.PositiveIntegerField(u"Колличество человек", null=True, blank=True)
info = models.CharField(u"Дополнительная информация", max_length=200, null=True, blank=True)
permanent = models.BooleanField(u"Ежедневный маршрут", default=True)
def __unicode__(self):
return u"{} - {}".format(self.start_point.city.name, self.end_point.city.name)
class DateRoute(models.Model):
DAYS_WEEK = (
(1, u"Понедельник"),
(2, u"Вторник"),
(3, u"Среда"),
(4, u"Четверг"),
(5, u"Пятница"),
(6, u"Суббота"),
(7, u"Воскресение")
)
MONTH_NUM = ([(x, x) for x in range(1, 32)])
date_start = models.DateField(u"Дата отправления", null=True, blank=True)
date_month = models.PositiveIntegerField(u"День месяца", null=True, blank=True, choices=MONTH_NUM)
week_num = models.PositiveSmallIntegerField(u"День недели", choices=DAYS_WEEK, null=True, blank=True)
route = models.ForeignKey(PassRoute, verbose_name=u"Маршрут")
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