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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:58:53+00:00 2026-05-26T19:58:53+00:00

Django newbie here stumbling my way around the docs. I’m trying to create a

  • 0

Django newbie here stumbling my way around the docs. I’m trying to create a user profile using Django’s “UserProfiles”, but I’m having a little trouble with figuring out the proper way to set the code based on Django docs.

Here’s my code, based on the docs. (The create_user_profile is 100% from the docs).

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


class UserProfile(models.Model):
    user = models.OneToOneField(User)

    location = models.CharField(max_length = 100)
    website = models.CharField(max_length=50)
    description = models.CharField(max_length=255)
    fullName = models.CharField(max_length=50)
    email = models.EmailField(max_length = 100, blank = False)
    created = models.DateTimeField(auto_now_add=True)
    private = models.BooleanField()


    def create_user_profile(sender, instance, created, **kwargs):
        if created:
            UserProfile.objects.create(user=instance)

    post_save.connect(create_user_profile, sender=User)

What’s the -proper- way to set and save these fields?

For example, if I have both the User and UserProfile models in one form (in a registration form, for example), how would I first create, then update all of this, before finally saving?

  • 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-05-26T19:58:54+00:00Added an answer on May 26, 2026 at 7:58 pm

    how would I first create, then update all of this, before finally saving

    These aren’t separate steps. When you create or update a record in Django, you are saving it to the database.

    For the registration form, I’d recommend you set it up as a ModelForm on User records, then specify the additional fields you want to save to the profile and save them separately in the save function, like so…

    class RegistrationForm(forms.ModelForm):
        location = forms.CharField(max_length=100)
        # etc -- enter all the forms from UserProfile here
    
        class Meta:
            model = User
            fields = ['first_name', 'last_name', 'email', and other fields in User ]
    
        def save(self, *args, **kwargs):
            user = super(RegistrationForm, self).save(*args, **kwargs)
            profile = UserProfile()
            profile.user = user
            profile.location = self.cleaned_data['location']
            # and so on with the remaining fields
            profile.save()
            return profile
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Django (and database) newbie here. I'm trying to figure out a way to enable
Django newbie here, I'm using render_to_response('example.html', { 'error_message': error_message, }, context_instance=RequestContext(request)) How do I
Django newbie at work and I could use some pointers. I'm using django-profile and
Python and django newbie question, here is code: class Client(User) #some fields client=Client() client.save()
Newbie question here. I am trying to use the django-extjs library in my django
Django newbie here, I'm using Django's i18n to translate my website. My templates get
Django newbie here, I need to do a count over a certain filter in
Django newbie here, I have several types of models, in each of them the
PostgreSQL / Django / newbie here. I've got a bunch of JSON data with
Django and south newbie here I need to change the encoding of a table

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.