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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:43:42+00:00 2026-06-07T10:43:42+00:00

I have a user registration form in my Django application which collects additional data

  • 0

I have a user registration form in my Django application which collects additional data while a user is trying to register such as address, city, country, phone number etc.

This data is saved in the Account model class through post_save signal. The user creation process goes something like this :

# Function to Create user Account/Profile
def create_user_account(sender, instance, created, **kwargs):
    if created:
      models.Account.objects.create(user=instance)

# Create User / User Registration
def UserRegistration(request):
    if request.method == 'POST':
        username = request.POST['fn'].capitalize() + ' ' + request.POST['ln'].capitalize()
        # CREATE USER
        newuser = User.objects.create_user(username=username, email=request.POST['email'], password=request.POST['pw'])
        newuser.first_name = request.POST['fn'].capitalize()
        newuser.last_name = request.POST['ln'].capitalize()
        newuser.save()
    return HttpResponse(username)

#Post Save handler to create user Account/Profile
post_save.connect(create_user_account, sender=User)

Here the UserRegistration function is called when a user posts a form and under this function, I can get the POST data, what I want is to pass that data to create_user_account method so that it fills in the fields in the Account model.

Right now, I do see Account objects created in the database, but all the fields except the user field are empty. Obviously, because the POST variables are not being passed to the create_user_account method.

  • 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-07T10:43:43+00:00Added an answer on June 7, 2026 at 10:43 am

    What I do is to set some ‘_attrs’ to the instance and then use them in the signal handler.

    I imagine your case could be:

    # Function to Create user Account/Profile
    def create_user_account(sender, instance, created, **kwargs):
        if created:
            attrs_needed = ['_language', '_field', '_otherfield']
            if all(hasattr(instance, attr) for attr in attr_needed):
                models.Account.objects.create(
                    user=instance, 
                    language=instance._language, 
                    field=instance._field,
                    otherfield=instance._otherfield)
    
    # Create User / User Registration
    def UserRegistration(request):
      if request.method == 'POST':
        username = request.POST['fn'].capitalize() + ' ' + request.POST['ln'].capitalize()
        # CREATE USER
        newuser = User.objects.create_user(
            username=username, email=request.POST['email'],
            password=request.POST['pw'])
        newuser.first_name = request.POST['fn'].capitalize()
        newuser.last_name = request.POST['ln'].capitalize()
    
        # Set some extra attrs to the instance to be used in the handler.
        newuser._language = request.POST['language']
        newuser._field = request.POST['field']
        newuser._otherfield = request.POST['otherfield']
        newuser.save()
    
    
      return HttpResponse(username)
    
    #Post Save handler to create user Account/Profile
    post_save.connect(create_user_account, sender=User)
    

    I hate to do this, and I imagine it can breaks in horrible ways, and is hard to debug sometimes, also there is no a strict way to force the data needed for the handler, one could define a signal_data(data, signal, instance) to define the data needed for the signal handler for a particular instance.

    A nice option that I haven’t tried is to use methods of the instance as signal’s handlers and maybe we can use a more structured way to pass the data.

    Bye.

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

Sidebar

Related Questions

In my web application i have registration form, when user register i want to
I have a user registration Form. If a new User register their account in
I want to make a user-registration form where I will have fields such first
Im new to django and trying to make a user registration form with few
I have a registration form that when the user enters in valid registration data
I'm making a registration form which will have the user put in his birthday.
I have simple user registration form. In which i am puting city as a
I am trying to create simple user registration form. I have an index.html file
Let's say I have an user registration form. In this form, I have the
I have to do a user registration form (classical layout with two columns, labels

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.