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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:06:26+00:00 2026-06-03T23:06:26+00:00

Some background, I’ve been designing a user profile for our Django database system and

  • 0

Some background,
I’ve been designing a user profile for our Django database system and am currently trying to create a views page to allow the user to edit their account settings (outside of the admin page). I have searched numerous sources, most of which recommend using .get_profile(), but this has not worked in my program no matter what approach I try (to my knowledge and research done). So far I have used the django main pages for .get_profile() to see how to properly use .get_profile() and found the AUTH_PROFILE_MODULE setting ( I will specify my settings in a bit).
Using this site:
http://www.turnkeylinux.org/blog/django-profile I found out some other methods of using .get_profile() but still nothing has worked. (I won’t add the rest of the links i’ve tried as I could go on for a while)

Back to the question, can anyone recommend a method that would work so that I can obtain the users information to set up some default values to maintain their current settings if they choose not to edit them and only update the ones with new submitted values.

So far I have: (hopefully all the relevant parts)

file directory:
~/Documents/project1

settings.py

AUTH_PROFILE_MODULE = "accounts.Account"

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`

File location:
project1/accounts

models.py

# additional model to incorporate our custom fields to the auth user model                                                                                   
class Account(models.Model):
    userLink = models.OneToOneField(User)      #link (pointer) to the users other     information in User model                                                  
    birthdate = models.DateField(blank = True) # True makes this field optional                                                                              
    gender = models.CharField(max_length = 1, choices = GENDER_CHOICE, null = True)

    def __unicode__(self):            # define a unicode for the user to access                                                                              
        return u'%s %s' % (self.userLink.first_name, self.userLink.last_name)   # return first and last name

# custom Form to change user account information (can't be a modelForm)                                                                                      
class EditAccountForm(forms.Form):
    gender = forms.CharField(max_length = 1)#, choices = GENDER_CHOICE, null = True)                                                                         
    birthdate = forms.DateField(widget = SelectDateWidget()) # True makes this field   optional

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

views.py

# Account settings view                                                                                                                                      
@login_required
def AccountSettings(request):
    sluggedSettingError = request.GET.get('error', '') # error message with slugged character                                                                
    settingError = sluggedSettingError.replace('-', ' ')
    settingForm = AdditionalForm(request.POST or None) # variable is called in     edit_user.html                                                                
    # might want to have some way to create a new profile if the account doesn't exist                                                                       
    userSettings = Account.objects.filter(userLink=request.user)
#    userSettings = request.user.get_profile() # returns the current settings of the     users profile                                                           
#### Currently trying to get it to let me use get_profile() ########                                                                                         
    print "userLink = %s" % userSettings#.user                                                                                                               
#    print "Gender = %s" % userSettings.gender # testing print                                                                                               
    if request.method == 'POST':
#        if settingForm.is_valid():                                                                                                                          
#            settingForm.save();                                                                                                                             
        return HttpResponseRedirect('/')
    return render_to_response("user_settings.html", {'settingForm': settingForm,   'settingError': settingError}, context_instance = RequestContext(request))
#        gender = request.POST['gender']  # pass in the gender variable from post                                                                            
#        birthdate = request.POST['birthdate']   # pass in the birthdate from post        

As the code is currently I gave up on the .get_profile() approach and tried doing a query through the available accounts until a matching userLink was found and then saving that to a variable “userSettings”. The approach I was taking was to use this variable as userSettings.gender, userSettings.birthdate etc. to access each of the users settings and have them changed if updated and set to the previous value if not (with a series of if statements or some built in Django function).

I’m not sure if this is the most efficient method, or if I should revert back to the get_profile() method. When I was using get_profile() (as it is typed currently in the commented out line) I got the following error
Cannot resolve keyword ‘user’ into field. Choices are: birthdate, gender, id, userLink

I also tried this approach with a new database using userLink defined as “user” instead to match what the django.docs website specified but still got an error about the Account not existing. I tried creating a try: and except: approach from
https://bitbucket.org/filmaster/filmaster-test/src/1618b18003ed/film20/userprofile/views.py
to handle this error but this also did not yield any positive results.

I am out of ideas on how to get .get_profile() to work, and can’t think of anything to allow me to access the users stored information so that it can be edited in a form by them. I’m not sure I understand how to utilize it properly at this point and feel like I’m just running around in circles at this point. If anyone can help me with this I’d appreciate it. I tried to give as much relevant information as I could, but if you need something else to help me out let me know and I will try to include it as soon as I can.

Thanks in advance!

  • 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-03T23:06:28+00:00Added an answer on June 3, 2026 at 11:06 pm

    To get the profile attached to a user object, you just need to call get_profile() on the user object:

    user.get_profile()
    

    For example,

    request.user.get_profile()
    

    The docs on it are in Django Docs. Its worth noting that

    The method get_profile() does not create a profile if one does not exist.

    So you have to have a trigger to create profiles on creating users …

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

Sidebar

Related Questions

Some background I'm currently working on a mobile site so I keep switching user
Some background. I am currently working on a distributed system in Java. The code
Some background information: We have an ancient web-based document database system where I work,
Some Background to begin: I've implemented a custom MembershipProvider that validates a user from
Some background: we have a windows application (c#) that locate in the system try.
First some background: I'm working on an application and I'm trying to follow MVVM
Just some background, sorry so long winded. I'm using the System.Data.SQLite ADO.net adapter to
I'm running some background threads in the GUI. Currently I'm implementing a personal Thread
Some background: I am attempting to create a DirectShow source filter based on the
Some background first. I am currently learning some stuff about monadic parser combinators. While

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.