03
Sep
11

django modelformset disallow empty forms



In order to disallow empty forms from being submitted to a ModelFormSet, do this in your formset:


class MyModelFormSet(BaseModelFormSet):
  def __init__(self,*args,**kwargs):
    super(MyModelFormSet,self).__init__(*args,**kwargs)
    for form in self.forms:
      form.empty_permitted = False

Advertisements

0 Responses to “django modelformset disallow empty forms”



  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Blog Stats

  • 228,134 hits

%d bloggers like this: