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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:43:07+00:00 2026-06-10T05:43:07+00:00

I am trying to follow the [Django Tutorial 6][1] to do the user authenication.

  • 0

I am trying to follow the [Django Tutorial 6][1] to do the user authenication. But i get stuck. I am getting this Attribute error: unicode’ object has no attribute ‘get’. The models,view and forms are provided below. Not sure where the error is… Need some help…

models.py

from django.db import models
from django.contrib.auth.models import User

class Drinker(models.Model):

    user = models.OneToOneField(User)
    birthday = models.DateField()
    name = models.CharField(max_length=100)

    def __unicode__(self):
        return self.name

views.py

from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from django.template import RequestContext
from drinker.forms import RegistrationForm
from django.contrib.auth.models import User
from drinker.models import Drinker


def DrinkerRegistration(request):
    if request.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.cleaned_data['password']
            user.save()
            drinker=Drinker(user=user,name=form.cleaned_data['name'],birthday=form.cleaned_data['birthday'])
            drinker.save()
            return HttpResponseRedirect('/profile/')
        else:
            return render_to_response('register.html',{'form':form,},context_instance=RequestContext(request))
    else:
        form = RegistrationForm()
        return render_to_response('register.html',{'form':form,},context_instance=RequestContext(request))

forms.py

from django import forms
from django.contrib.auth.models import User
from django.forms import ModelForm
from drinker.models import Drinker 

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

    class Meta:
        model = Drinker
        exclude = ('user',)

    def clean_username(self):
        username = self.cleaned_data['username']
        try:
            User.objects.get(username=username)
        except User.DoesNotExist:
            return username
        raise forms.ValidationError("That username is already taken. Please select another")
    def clean(self):
        password = self.cleaned_data['password']
        password1= self.cleaned_data['password1']
        if password and password1 and password != password1:
            raise forms.ValidationError("The passwords did not match. Please try again")
        return password

error:

Environment:


Request Method: POST

Django Version: 1.4
Python Version: 2.7.1
Installed Applications:
('django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'django.contrib.admindocs',
 'drinker')
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 "/Users/cnnlakshmen_2000/Projects/env/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/Users/cnnlakshmen_2000/Projects/Permissions/drinker/views.py" in DrinkerRegistration
  12.       if form.is_valid():
File "/Users/cnnlakshmen_2000/Projects/env/lib/python2.7/site-packages/django/forms/forms.py" in is_valid
  124.         return self.is_bound and not bool(self.errors)
File "/Users/cnnlakshmen_2000/Projects/env/lib/python2.7/site-packages/django/forms/forms.py" in _get_errors
  115.             self.full_clean()
File "/Users/cnnlakshmen_2000/Projects/env/lib/python2.7/site-packages/django/forms/forms.py" in full_clean
  272.         self._post_clean()
File "/Users/cnnlakshmen_2000/Projects/env/lib/python2.7/site-packages/django/forms/models.py" in _post_clean
  311.         exclude = self._get_validation_exclusions()
File "/Users/cnnlakshmen_2000/Projects/env/lib/python2.7/site-packages/django/forms/models.py" in _get_validation_exclusions
  297.                 field_value = self.cleaned_data.get(field, None)

Exception Type: AttributeError at /register/
Exception Value: 'unicode' object has no attribute 'get'
  • 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-10T05:43:08+00:00Added an answer on June 10, 2026 at 5:43 am

    You’re returning password from the clean() method, rather than self.cleaned_data.

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

Sidebar

Related Questions

I'm trying to follow the Django tutorial (for v1.1) here . the problem that
Im trying to follow a tutorial that is using SBJsonParser to get twitter feeds,
I'm trying to follow the django tutorial and create two tables where the unique
Evening, Trying to follow the Django tutorial, as seen here, https://docs.djangoproject.com/en/dev/intro/tutorial01/ I run the
I am trying to create very first project using django but stuck at very
I am trying to follow the django tutorial. I am running on windows+eclipse. When
I'm trying to follow the documentation to get started with celery, but running into
Trying to create a Django app based off the tutorial but using a different
Iam new to django-haystack, and I am trying to follow the getting started guide.
i'm trying to follow this explanation: https://developers.google.com/appengine/docs/python/tools/uploadingdata#Downloading_and_Uploading_All_Data but when i add to my app.yaml:

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.