Django的营业时间

编程入门 行业动态 更新时间:2024-10-27 06:32:56
本文介绍了Django的营业时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想添加诊所的营业时间,并且已经研究了这个实施营业时间"的任何现有解决方案在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的营业时间

本文发布于:2023-10-23 01:38:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1519355.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:营业时间   Django

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!