我想添加诊所的营业时间,并且已经研究了这个实施营业时间"的任何现有解决方案在Django 中,但这对我来说不合适.因为这假设您在所有工作日都具有相同的时间设置,而在特殊的日子具有相同的时间设置.鉴于我希望各天有不同的开放时间.此外,我希望一天有不止1个条目.例如,周日的诊所从上午8:30-下午12:00营业,并从下午4:30-晚上10点再次营业.
I want to add Business hours for a clinic and I've looked into this Any existing solution to implement "opening hours" in Django but it's not right for me. Because this one assumes you'll have same set of hours for all the weekdays and same set of hours for special days. Whereas, I want to have different opening hours for individual days. Moreover, I want to have more than 1 entry for an individual day. For instance, a clinic on Sunday runs from 8:30 am - 12:00 pm and opens again from 4:30 pm - 10 pm.
我希望能够从管理面板添加它,类似于Yelp
I want to be able to add this from the admin panel, similar to Yelp
推荐答案
恕我直言,链接中的解决方案几乎可以满足您的要求.只需对其进行一些自定义即可:
IMHO the solution from the link is doing almost exactly what you want. Just customize it a bit:
WEEKDAYS = [ (1, _("Monday")), (2, _("Tuesday")), (3, _("Wednesday")), (4, _("Thursday")), (5, _("Friday")), (6, _("Saturday")), (7, _("Sunday")), ] class OpeningHours(models.Model): weekday = models.IntegerField(choices=WEEKDAYS) from_hour = models.TimeField() to_hour = models.TimeField() class Meta: ordering = ('weekday', 'from_hour') unique_together = ('weekday', 'from_hour', 'to_hour') def __unicode__(self): return u'%s: %s - %s' % (self.get_weekday_display(), self.from_hour, self.to_hour)更多推荐
Django的营业时间
发布评论