Hi - I'm a django newbie, so sorry if I'm doing something stupid (I did try to read the documentation.
I want to have a model, that has a manytomany field that stores days of the week, selected via a checkbox widget. I read on the web, that I could put something like this in the model. DAYS_OF_WEEK = (('1', 'Monday'),('2', 'Tuesday'),('3', 'Wednesday'),('4', 'Thursday'),('5', 'Friday'),('6', 'Saturday'),('7', 'Sunday'),) class Days(models.Model): days = models.CharField(max_length=1, choices=DAYS_OF_WEEK) The part of the model that references the days: class Preferences(models.Model): mail_days = models.ManyToManyField(Days) The part of the form where the days are selected, is here: DAYS_OF_WEEK = ( ('1', 'Monday'), ('2', 'Tuesday'), ('3', 'Wednesday'), ('4', 'Thursday'), ('5', 'Friday'), ('6', 'Saturday'), ('7', 'Sunday'), ) mail_days = forms.MultipleChoiceField(required=False, widget=CheckboxSelectMultiple, choices=DAYS_OF_WEEK) The form displays correctly, i.e. checkboxes for the days of the week appear. When I select the boxes, and hit submit, everything looks ok. But if I redisplay the form , the checkboxes are all empty. But changes to the other form fields, that I made, get saved properly (As an aside, I'm using form.save(), not using commit=False). So why do my checkboxes selections disappear? Here's the SQL database table, that gets created for the days model. It's empty. It's not populated with anything. Shouldn't it be? CREATE TABLE `myapp_days` ( `id` int(11) NOT NULL AUTO_INCREMENT, `days` varchar(1) NOT NULL, PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1; LOCK TABLES `todo_days` WRITE; UNLOCK TABLES; The selected days are getting saved into a table called myapp_preferences_my_days. So something is being saved. Is this a model problem, or form problem? Thanks.- Mark CREATE TABLE `myapp_preferences_mail_days` ( `id` int(11) NOT NULL AUTO_INCREMENT, `preferences_id` int(11) NOT NULL, `days_id` int(11) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `preferences_id` (`preferences_id`,`days_id`), KEY `myapp_preferences_mail_days_2d9474d5` (`preferences_id`), KEY `myapp_preferences_mail_days_96c2dc77` (`days_id`) ) ENGINE=MyISAM AUTO_INCREMENT=16 DEFAULT CHARSET=latin1; LOCK TABLES `myapp_preferences_mail_days` WRITE; INSERT INTO `myapp_preferences_mail_days` VALUES (15,1,6),(14,1,4),(13,1,5); UNLOCK TABLES; -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.