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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:56:24+00:00 2026-06-17T12:56:24+00:00

I have created my UserProfile model as instructed in the docs but how can

  • 0

I have created my UserProfile model as instructed in the docs but how can I pass the values to be saved from my view. This is how my view looks like:

if request.method == 'POST':
    form = RegistrationForm(request.POST)
    if form.is_valid():
        now = timezone.now()
        user = User.objects.create(
            username     = form.cleaned_data['username'],
            first_name   = form.cleaned_data['username'],
            last_name    = form.cleaned_data['username'],
            email        = form.cleaned_data['email'],
            is_staff     = False,
            is_active    = False,
            is_superuser = False,
            last_login   = now,
            date_joined  = now
        )

    user.set_password(form.cleaned_data['password'])
    user.save()
  • 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-17T12:56:25+00:00Added an answer on June 17, 2026 at 12:56 pm

    Update 1

    Since, you are using post_save() signal on User model to create UserProfile object, you can access newly created profile user after calling user.save()

    profile = user.get_profile()
    profile.verified = False
    profile.ip_address = get_client_ip()
    profile.save()
    

    I assume, you have UserProfile model in your models.py.

    ## Create a forms.py file inside your app and define an UserProfileForm similar to this
    
    from django.forms import ModelForm
    
    ## using relative import because it's good practice, and I don't know what's name of your app
    from .models import UserProfile
    
    class UserProfileForm(ModelForm)
        class Meta:
            model = UserProfile
            exclude = ("user",)
    
    
    ## In views.py
    
    if request.method == 'POST':
        form = RegistrationForm(request.POST)
        profile_form = UserProfileForm(request.POST)
        if form.is_valid() and profile_form.is_valid():
            now = timezone.now()
            user = User.objects.create(
                username     = form.cleaned_data['username'],
                first_name   = form.cleaned_data['username'],
                last_name    = form.cleaned_data['username'],
                email        = form.cleaned_data['email'],
                is_staff     = False,
                is_active    = False,
                is_superuser = False,
                last_login   = now,
                date_joined  = now
            )
    
        user.set_password(form.cleaned_data['password'])
        user.save()
        profile = profile_form.save(commit=False)
        profile.user = user
        profile.save()
    

    However, I don’t understand why are you not using your RegistrationForm even after initializing and validating it.

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

Sidebar

Related Questions

having read the docs, https://docs.djangoproject.com/en/dev/topics/signals/ i have created this in my signals.py file: from
I have two models: UserProfile (extended from user) and Cv . I created another
I have created 3 classes as following Ext.mine.TextParent - Inherting from Textfield Ext.mine.child.TextChildA -
I have an extended UserProfile model in django: class UserProfile(models.Model): user = models.ForeignKey(User, unique=True)
I have a simple set up of User and UserProfile model with User has_one
I have separate apps with a foreign key from a model in one model
I have created the following M2M table with an intermediary model -- class Position(models.Model):
I have the following two models: class Position(models.Model): position = models.CharField(max_length=100) class UserProfile(models.Model): user
I have the the following Django model: class UserProfile(models.Model): user = models.ForeignKey(User, unique=True) full_name
I have model UserProfile with field avatar = models.ImageField(upload_to=upload_avatar) upload_avatar function names image file

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.