Opened 17 years ago

Closed 17 years ago

#6525 closed (worksforme)

ModelForm requires fields set to null=True, blank=True ?

Reported by: pat.j.anderson@… Owned by: nobody
Component: Forms Version: dev
Severity: Keywords: ModelForm
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I have a model which goes like this:

class Announcement(models.Model):
    """
    Data model for announcements
    """
    
    language            = models.ForeignKey(Language)
    regions             = models.ManyToManyField(Region)
    countries           = models.ManyToManyField(Country, null = True, blank = True)
    ...

and an Announcement form which extends ModelForm:

{{
class AnnouncementForm(forms.ModelForm):

class Meta:

model = Announcement
exclude = ('time_trashed',)

}}}

Now I pre-select a single Country from user profile, as a convenience, using form.fieldscountries.initial when I display the form. When a user deselect that Country in the form, and tries to save it, form.save() fails without an error. When I select some countr(ies), form.save() works.

Change History (1)

comment:1 by Matt McClanahan, 17 years ago

Resolution: worksforme
Status: newclosed

I can't reproduce this. I suggest bringing the matter up on the django-users mailing list, or the #django IRC channel.

Note: See TracTickets for help on using tickets.
Back to Top