On Jun 2, 3:00 am, HARRY POTTRER <cp368...@ohio.edu> wrote: > I have a models that represents an event. > > I want it to have a field that represents the days of the week that > the event occurs. This is easy if all you need to be able to do is be > able to select one day, but if you want to select multiple, the right > way seems to be to create a DayOfWeek object, create 7 instances in > your db, the use ManyToMany relations. To me that just seems wrong. > I'd rather store it as a string like "WFS" or "MWF". Is there an easy > way to do this in django?
You may want to think about storing the weekdays as numeric equivalents e.g. 0 = Sunday, 1 = Monday etc. Then you could use a CommaSeparatedIntegerField to store any combo you need - see: http://docs.djangoproject.com/en/dev/ref/models/fields/#commaseparatedintegerfield http://stackoverflow.com/questions/1208698/how-do-i-use-commaseparatedintegerfield-in-django http://www.pubbs.net/200908/django/9885-how-to-use-selectmultiple-widget-with-commaseparatedintegerfield-.html Alternatively, you write a custom field - see: http://www.davidcramer.net/code/181/custom-fields-in-django.html -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.