Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6232171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:04:17+00:00 2026-05-24T10:04:17+00:00

I want to add an extra field to a ModelForm. It seems easy, but

  • 0

I want to add an extra field to a ModelForm. It seems easy, but I get the following error:

Django Version: 1.4 pre-alpha SVN-16573
Exception Type: TypeError
Exception Value:    
argument of type 'NoneType' is not iterable
Exception Location: /usr/local/lib/django-trunk/django/forms/models.py in construct_instance, line 39
Python Executable:  /usr/bin/python
Python Version: 2.6.6

This is the code:

class NodeForm(forms.ModelForm):
    password2 = forms.CharField(max_length=20, required=True, widget=forms.PasswordInput())

    class Meta:
        model = Node

    def __init__(self, *args, **kwargs):
        super(NodeForm, self).__init__(*args, **kwargs)
        # css classes for fields
        for v in self.fields:
            self.fields[v].widget.attrs['class'] = 'text ui-widget-content ui-corner-all'

    def clean(self):
        ''' Calls parent clean() and performs additional validation for the password field '''
        super(NodeForm, self).clean()
        password = self.cleaned_data.get('password')
        password2 = self.cleaned_data.get('password2')
        # password and password2 must be the same
        if password != password2:
            raise forms.ValidationError('I due campi password non corrispondono.')

I was not able to fix it. What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T10:04:17+00:00Added an answer on May 24, 2026 at 10:04 am

    You should return cleaned data from clean method as documented here
    That is:

    def clean(self):
        # perform checks
        return self.cleaned_data
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to add an extra field to my query that will have the
I want to add an extra field in 'edit review' in Magento admin. Where
I want to add extra infos for some fields of a django form, and
I want to add an extra file uploading field to joomla 2.5 registration form
I just want to add some extra text on top of input posted from
Suppose I have a Python class that I want to add an extra property
I want add UIGestureRecognizerDelegate to UIWebView,but failed. if [self.view addsubView:webView]; So UIWebView is ok,but
I created a ModelSerializer and want to add a custom field which is not
So, the extra field in a queryset can be used to add additional columns
Basically when the meta_key field is equal to 'location' I want to add an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.