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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:29:47+00:00 2026-05-13T10:29:47+00:00

I have a simple question. This is my profile: class Profile(models.Model): user = models.ForeignKey(User,

  • 0

I have a simple question. This is my profile:

class Profile(models.Model):

    user = models.ForeignKey(User, unique=True)
    born = models.DateTimeField('born to')    
    photo = models.ImageField(upload_to='profile_photo')

I want to create a registration form with these fields (from User and Profile models):

  • username
  • first_name
  • last_name
  • born
  • photo

These fields are required.

How do I do that?

How does get_profile() work in a template for this issue?

Thank you 🙂

  • 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-13T10:29:48+00:00Added an answer on May 13, 2026 at 10:29 am

    Setup

    Are you using the django-profiles and django-registration projects? If not, you should—much of this code has already been written for you.

    Profile

    Your user profile code is:

    class Profile(models.Model):
        user = models.ForeignKey(User, unique=True)
        born = models.DateTimeField('born to')    
        photo = models.ImageField(upload_to='profile_photo')
    

    Have you correctly setup this profile in your Django settings? You should add this if not, substituting yourapp for your app’s name:

    AUTH_PROFILE_MODULE = "yourapp.Profile"
    

    Registration Form

    django-registration comes with some default registration forms but you specified you wanted to create your own. Each Django form field defaults to required so you should not need to change that. The important part is just making sure to handle the existing registration form fields and adding in the profile creation. Something like this should work:

    from django import forms
    from registration.forms import RegistrationForm
    from yourapp.models import Profile
    from registration.models import RegistrationProfile
    
    class YourRegistrationForm(RegistrationForm):
        born = forms.DateTimeField()
        photo = forms.ImageField()
    
        def save(self, profile_callback=None):
            new_user = RegistrationProfile.objects.create_inactive_user(username=self.cleaned_data['username'],
            password=self.cleaned_data['password1'],
            email = self.cleaned_data['email'])
            new_profile = Profile(user=new_user, born=self.cleaned_data['born'], photo=self.cleaned_data['photo'])
            new_profile.save()
            return new_user
    

    Bringing it together

    You can use the default django-registration templates and views, but will want to pass them your form in urls.py:

    from registration.backends.default import DefaultBackend
    from registration.views import activate
    from registration.views import register
    
    # ... the rest of your urls until you find somewhere you want to add ...
    
    url(r'^register/$', register,
        {'form_class' : YourRegistrationForm, 'backend': DefaultBackend},
        name='registration_register'),
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is hopefully a simple question: I have an OpenGL texture and would like
This is a (hopefully) really simple question - I have been told recently that
Okay this may be a simple question but I have yet to come with
I know this is a simple question for someone out there, but I have
this is a simple question. I have a form that is being validated using
This is probably a simple question, but i have been unable to find a
Simple question: I have the following markup... <a href='#'> <img src='icon.png'> This is the
This is a real newbie question. I have simple app that selects a picture
I'm rather new to WPF, so maybe this is a simple question. I have
This is a simple htaccess question for experts but I have been trying to

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.