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 9006435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:24:39+00:00 2026-06-16T01:24:39+00:00

Could anyone help explain the following error and what it means in relation to

  • 0

Could anyone help explain the following error and what it means in relation to the code below?

All I’m trying to do is save a form.

error

    TypeError at /member/registration/
    list indices must be integers, not str
/Users/user/Documents/workspace/Hera/member/views.py in registration, line 17

nvironment:


Request Method: POST
Request URL: http://127.0.0.1:8000/member/registration/

Django Version: 1.4.2
Python Version: 2.7.2
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.flatpages',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'grappelli.dashboard',
 'grappelli',
 'django.contrib.admin',
 'django.contrib.admindocs',
 'web',
 'member',
 'rest_framework')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/Users/user/Documents/workspace/Hera/member/views.py" in registration
  17.             user = User.objects.create_user(username=form.cleaned_data['username'],email=form.cleaned_data['email'], password=form.changed_data['password'])

Exception Type: TypeError at /member/registration/
Exception Value: list indices must be integers, not str

views.py

def registration(request):
    if request.user.is_authenticated():
        return HttpResponseRedirect('/error')
    if request.method == 'POST':
        form = RegistrationForm(request.POST)
        if form.is_valid():
            user = User.objects.create_user(username=form.cleaned_data['username'],email=form.cleaned_data['email'], password=form.changed_data['password'])
            user.save()
            member = User.get_profile()
            member.name = form.cleaned_data['name']
            member.save()
            return HttpResponseRedirect('/profile')
        else:
            return render_to_response('pageRegistration.html', {'form':form},context_instance=RequestContext(request))

    else: 
        form = RegistrationForm 
        context = {'form':form}
        return render_to_response('pageRegistration.html', context, context_instance=RequestContext(request))

models.py

class Member (models.Model):
    user =  models.OneToOneField(User)
    name = models.CharField(max_length=100)

    def __unicode__(self):
        return self.name

def createUserCallBacks(sender, instance, **kwargs):
    member, new = Member.objects.get_or_create(user=instance)
post_save.connect(createUserCallBacks, User)

forms.py

class RegistrationForm(ModelForm):
    username = forms.CharField(label=(u'User Name'))
    email = forms.EmailField(label=(u'Email'))
    password = forms.CharField(label=(u'Password'), widget=forms.PasswordInput(render_value=False))
    passwordConfirm = forms.CharField(label=(u'Confirm Password'), widget=forms.PasswordInput(render_value=False))

    class Meta:
        model = Member
        # Don't show user drop down.
        exclude = ('user',)



    def clean(self):
        cleaned_data = super(RegistrationForm, self).clean()
        try:        
            password = cleaned_data['password']
            passwordConfirm = cleaned_data['passwordConfirm']
            if password != passwordConfirm:
                raise forms.ValidationError("Password does not match, try again.")
            return cleaned_data
        except:
            raise forms.ValidationError("Password does not match, try again.")

        username = cleaned_data['username']
        try: User.objects.get(username=username)
        except User.DoesNotExist:
            return username
        raise forms.ValidationError("Username already taken, try another.")

updated def clean

  def clean(self):
        try:   
            cleaned_data = super(RegistrationForm, self).clean() 
            password = cleaned_data.get("password")
            passwordConfirm = cleaned_data.get('passwordConfirm')

            if password != passwordConfirm:
                raise forms.ValidationError("Password does not match, try again.")
            return cleaned_data
        except:
            raise forms.ValidationError("Error")
  • 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-06-16T01:24:40+00:00Added an answer on June 16, 2026 at 1:24 am

    I wish you had posted the full traceback, then it would have been much easier to solve your problem.

    However I guess it is because you are randomly returning things in your clean function. You have return cleaned_data at one point, but then after that you have return username. You do need to return cleaned_data from this function, but you should be doing at the end, otherwise you will never actually get to the second validator.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could anyone help me to understand following line of code: sol< ?=f((1<< n)-1,i,0)+abs(P[i])*price; I
Could anyone help me in assessing why the code below doesn't work. I'm using
Could anyone please help me convert this code to vb.net, I have tried it
Could anyone explain the following two lines please? RewriteEngine on RewriteRule ^(.*)-(.*)-(.*)$ index.php?page=$1&id=$2&im=$3 I
Could anyone help to explain how can I interact with message loop in WPF?
Could anyone please help me using C# Api in Z3. I have no idea
Ok so could anyone please help me out with the VB for auto entering
I wonder if anyone could help me with a problem I've been having. I
I was wondering if anyone could help me implement color selection in my iOS
Im asking to see if anyone could help me with my problem which is

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.