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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:43:34+00:00 2026-06-12T08:43:34+00:00

i’ve a probelem with the request.user.is_authenticated() this the view. from django.http import HttpResponseRedirect from

  • 0

i’ve a probelem with the request.user.is_authenticated()
this the view.

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

def ContributorRegistration(request):
    if request.user.is_authenticated():
        '''if user is logged in -> show profile'''
        return HttpResponseRedirect('/profile/')
    if request.method == 'POST':
        '''if post, check the data'''
        form = ContributorRegistration(request.POST)
        if form.is_valid():
            ''' if form is valid, save the data'''
            user = User.objects.create_user(username=form.cleaned_data['username'],email = form.cleaned_data['email'], password= form.cleaned_data['password'])
            user.save()
            contributor = user.get_profile()
            contributor.location = form.cleaned_data['location']
            contributor.save()
            return HttpResponseRedirect('profile.html')
        else:
            '''form not valid-> errors'''
            return render_to_response('register.html',{'form':form},context_instance=RequestContext(request))
    else: 
        '''method is not a post and user is not logged, show the registration form'''
        form = RegistrationForm()
        context={'form':form}
        return render_to_response('register.html',context,context_instance=RequestContext(request))

basically,
if the user is logged in then the profile.html is shown: OK
if the user is not logged in and he’s not posting data then the form is shown: OK
when i submit the data from the form i receive back this error:

Request Method: POST
Request URL:    http://localhost:8000/register/
Django Version: 1.4.1
Exception Type: AttributeError
Exception Value:    
'QueryDict' object has no attribute 'user'
Exception Location: /Users/me/sw/DjangoProjects/earth/views.py in ContributorRegistration, line 9

where line 9 is if request.user.is_authenticated():
so seems that the request does not have the user object when submitting the form data.
how can i solve?
Thanks

  • 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-12T08:43:35+00:00Added an answer on June 12, 2026 at 8:43 am

    You’re filling your own view function with the request.POST data as if it was the form.

    if request.method == 'POST':
        '''if post, check the data'''
        form = ContributorRegistration(request.POST)
        if form.is_valid():
    

    Should be

    if request.method == 'POST':
        '''if post, check the data'''
        form = RegistrationForm(request.POST)
        if form.is_valid():
    

    In order to have access to request.user object, you need to have the User authentication middleware installed in your application. To do this (extremely easy), do the following:

    Go to your settings.py and add 'django.contrib.auth' and 'django.contrib.contenttypes' to the INSTALLED_APPS tupple.

    You are very likely to require a syncdb command for it to be fully installed (you need some database tables for user authentication).

    python manage.py syncdb
    

    And that should make it work.

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

Sidebar

Related Questions

I have a view passing on information from a database: def serve_article(request, id): served_article
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
This could be a duplicate question, but I have no idea what search terms

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.