Thanks for the help guys. On Fri, Jun 29, 2012 at 11:37 AM, Sunny Nanda <snand...@gmail.com> wrote:
> One way to store such information can be like this: > Create a model "Day". This will hold entries for each day i.e. from Monday > till Sunday > In the UserProfile model, create a ManyToMany relation to the above > defined Day model through an intermediate table (say WorkingHours) which > can hold the "from" and "to" time. > > Partial example below: > > class UserProfile(models.Model): >> working_hours = models.ManyToManyField("Day", through="WorkingHours") >> >> class WorkingHours(models.Model) >> profile = models.ForeignKey("UserProfile") >> day = models.ForeignKey("Day") >> from_time = models.**TimeField() >> to_time = models.**TimeField() >> > > While creating the forms, take input from the user for the WorkingHours > model. This way, the days of work will not be hardcoded, and user can > select mutiple choices. > > Regards, > Sandeep > > > > On Friday, June 29, 2012 10:16:47 AM UTC+5:30, Nikhil Verma wrote: >> >> >> Hi >> >> I am developing an event app which has users who publish events , other >> users also. >> Now users have their profile info for which i have made a very common >> UserProfile Model with all the necessary details in it. >> >> I have a requirement where in UserProfile model i need to display a field >> institue_hours_of_operation( no. of hours that an institute works) >> >> >> class UserProfile(models.Model): >> user = models.ForeignKey(User, blank=True, null=True, unique=True) >> first_name = models.CharField(max_length=**30, blank=True) >> last_name = models.CharField(max_length=**30, blank=True) >> gender = models.CharField(max_length=1, choices=GENDER_CHOICES, >> blank=True) >> birth_date = models.DateField(auto_now_add=**True) >> street_address = models.CharField(max_length=**75, blank=True) >> city = models.CharField(max_length=**30, blank=True) >> zip_code = models.IntegerField(max_**length=7, blank=True, null=True) >> country = models.CharField(max_length=**30, blank=True) >> mobile = models.CharField(max_length=**15, blank=True) >> home_phone = models.CharField(max_length=**15, blank=True) >> primary_email = models.EmailField(max_length=**60, blank=True) >> secondary_email = models.EmailField(max_length=**60, blank=True) >> institution_name = models.CharField(max_length=** >> 100,blank=True,null=True) >> institution_website = models.CharField(max_length=** >> 100,blank=True,null=True) >> >> >> # Field to be added >> >> It will be displayed in html like this >> >> Insitutue hour of operation : Monday 9.00 - 17.00 (Monday will be >> hardcoded,Time will be filled by user) >> ** Tuesday 9.00 - 17.00 >> (Monday will be hardcoded,Time will be filled by user) >> >> ** and so on >> >> # Note the weekdays like monday, tuesday they are all hardcoded as >> requirement but i don't want that to be hardcoded. >> Also i am using a django forms to display this. >> >> >> How can i design this form field as well in models or What should be the >> type of this field both in models and forms such that weekdays remain >> dynamic(i can simply generate them from loop) and the user can fill the >> time and when he hits submit it will get saved. >> >> >> Thanks in advance. >> >> >> >> -- >> Regards >> Nikhil Verma >> +91-958-273-3156 >> >> -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/django-users/-/N2ArPbWtQmYJ. > > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- Regards Nikhil Verma +91-958-273-3156 -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.