Django Error: ‘Form’ object has no attribute ‘get’

Suppose you get this error while trying to render a page that has a form:

‘Form’ object has no attribute ‘get’

Did you use super correctly??? Or did you make the dreaded “cut and paste” error:

class FormWithError(forms.ModelForm):
    class Meta:
        model = MyModel

    def __init__(self, *args, **kwargs):
        super(FormWithError, self).__init__(self, *args, **kwargs)


 class FormWithOutError(forms.ModelForm):
    class Meta:
        model = MyModel

    def __init__(self, *args, **kwargs):
        super(FormWithError, self).__init__(*args, **kwargs)

Note the extra “self” in the super().__init__.

Feel free to slap yourself in the head.

Advertisements

One thought on “Django Error: ‘Form’ object has no attribute ‘get’

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