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

  • Home
  • SEARCH
  • 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 8858743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:53:50+00:00 2026-06-14T14:53:50+00:00

hello i’m new in python and django I need a view that get current

  • 0

hello i’m new in python and django
I need a view that get current user profile I know I shoud use get_profile from User but I don’t know how to use it . i read the django document and It didn’t help me.
this is what I found from doc:

from django.contrib.auth.models import User
profile=request.user.get_profile()
  • 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-14T14:53:52+00:00Added an answer on June 14, 2026 at 2:53 pm

    Django’s documentation says it all, specifically the part Storing additional information about users. First you need to define a model somewhere in your models.py with fields for the additional information of the user:

    models.py

    from django.contrib.auth.models import User
    
    class UserProfile(models.Model):
        # This field is required.
        user = models.OneToOneField(User)
    
        # Other fields here
        accepted_eula = models.BooleanField()
        favorite_animal = models.CharField(max_length=20, default="Dragons.")
    

    Then, you need to indicate that this model (UserProfile) is the user profile by setting AUTH_PROFILE_MODULE inside your settings.py:

    settings.py

    ...
    AUTH_PROFILE_MODULE = 'accounts.UserProfile'
    ...
    

    You need to replace accounts with the name of your app. Finally, you want to create a profile every time a User instance is created by registering a post_save handler, this way every time you create a user Django will create his profile too:

    models.py

    from django.contrib.auth.models import User
    
    class UserProfile(models.Model):
        # This field is required.
        user = models.OneToOneField(User)
    
        # Other fields here
        accepted_eula = models.BooleanField()
        favorite_animal = models.CharField(max_length=20, default="Dragons.")
    
    
    def create_user_profile(sender, instance, created, **kwargs):
        if created:
            UserProfile.objects.create(user=instance)
    
    post_save.connect(create_user_profile, sender=User)
    

    Accessing the Profile

    To access the current user’s profile in your view, just use the User instance provided by the request, and call get_profile on it:

    def your_view(request):
        profile = request.user.get_profile()
        ...
        # Your code
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hello for my app I need to save a record that the user type,
Hello does any one know that setting I need to ON for connect to
Hello I have like this 2 tables class User public int UserId{get;set;} { ....
Hello I want to get Accurate location so that i have used following link
Hello I have this problem with PyQt4-dev-tools that include: * a user interface compiler
Hello I want to know how to highlight all Words that is inputted in
hello friends i am trying to get a list of user id and want
Hello guys I need to pass a string array over to a setter that
Hello ! I need to create a report like the attachment shows with Jasper
Hello I've got this query to get users by email, which is an unique

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.