On 29-6-2012 11:01, Nikhil Verma wrote:
> Yes it is the count of the hours.They will enter in the following manner "-
>
> Monday : 0900-1800, Tuesday and so on ... This will be entered by the user
> who is filling the form.
>
> Now the text Moday(weekdays can be hardcoded but i personally don't want.)
Untested, but I'd try this:
class DaysOfWeek(models.Model) :
name = models.CharField(max_length=32)
class BusinessHours(models.Model) :
day = models.ForeignKey(DaysOfWeek)
start = models.TimeField()
end = models.TimeField()
class Institute(models.Model) :
# ...
business_hours = models.ManyToManyField(BusinessHours)
Not sure if the Admin handles this ok though. An alternative:
class DaysOfWeek(models.Model) :
name = models.CharField(max_length=32)
def __iter__(self) :
return self
def next(self) :
for entry in DaysOfWeek.objects.all() :
return (entry.id, entry.name)
class BusinessHours(models.Model) :
day = models.CharField(max_length=32, choices=DaysOfWeek)
start = models.TimeField()
end = models.TimeField()
--
Melvyn Sopacua
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment