Yes, here is the view code form = group_forms.GroupForm(request.POST, instance=group) options_form = group_forms.GroupOptionForm(request.POST, instance=group.groupoption_set.all()[0]) if form.is_valid() and options_form.is_valid(): form_instance = form.save(commit=False) form_instance.save() options_form.save()
I have printed instance=group.groupoption_set.all()[0] and it is the correct instance of GroupOption. The options also save correctly. Thanks On Nov 4, 4:08 pm, Daniel Roseman <dan...@roseman.org.uk> wrote: > On Nov 4, 3:58 pm, chewynougat <peter_i_campb...@hotmail.co.uk> wrote: > > > > > Hi > > > When I want a user to edit a form, I would like previously checked > > checkboxes to show as checked. However, they are not showing (just > > unchecked checkboxes). Can anyone explain to me why this is? > > > Model: > > > class GroupOption(models.Model): > > group = models.ForeignKey(Group) > > media = models.BooleanField(default=False, blank=True) > > routes = models.BooleanField(default=False, blank=True) > > medals = models.BooleanField(default=False, blank=True) > > > Form: > > > class GroupOptionForm(forms.ModelForm): > > media = forms.BooleanField(widget=forms.CheckboxInput, label="Enable > > photo/video sharing", required=False) > > routes = forms.BooleanField(widget=forms.CheckboxInput, > > label="Enable > > route sharing", required=False) > > medals = forms.BooleanField(widget=forms.CheckboxInput, label="Allow > > group member medals to be displayed", required=False) > > > class Meta: > > model = group_models.GroupOption > > exclude = ('group',) > > > thanks in advance! > > Are you passing the existing instance when the form is instantiated? > Show us the views code. > -- > DR. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---