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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:59:19+00:00 2026-05-20T17:59:19+00:00

So, I have an idea to build a web app. I am new to

  • 0

So, I have an idea to build a web app. I am new to this business but am a programmer. I liked Python and thought let me start with Django. I ran into a problem with the built-in Django User Auth system as pointed by this question of mine on SO.

In short, I am using Django’s built-in User auth and thought that it will easily fill my user field (the foreignkey) in my model but it does not. I have Googled and asked questions but only got a very convoluted answer or that I have to use the Admin section if I want anything like that.

My simple need is that whenever user saves anything in their profile, the user field should get populated so that I can reference it. To me, it sounds like the most basic need for any web app.

Am I wrong. I need advice. If Django is not good for this then I am ready to learn any other good framework or platform if need be.

  • 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-20T17:59:20+00:00Added an answer on May 20, 2026 at 5:59 pm

    In short, I am using Django’s built-in
    User auth and thought that it will
    easily fill my user field (the
    foreignkey) in my model but it does
    not.

    This won’t just magically happen. You will have make it happen. Models are separated from the request so this would happen in your view, or a model method (perhaps save) that is passed the active user.

    MVC / MTV design separates the database from the view / control logic. I don’t see what framework has to do with this: unless you write the functionality yourself, the database doesn’t know what to do with some User table and the currently logged in user (also separated from the data). Building in this functionality would inconvenience a lot of people as well…

    In general, the python/django philosophy is: Explicit is better than implicit.

    Now the solutions:

    If you wanted this behavior in the view, for any form, you could potentially write:

    instance = MyForm.save(commit=False) # commit=False prevents DB save.
    instance.user = request.user
    instance.save()
    

    You could overwrite the save method on the model that accepts an optional user argument as well.

    def save(self, *args, **kwargs):
        user = kwargs.pop(user, None)
        self.user = user
        super(MyModel, self).save(*args, **kwargs)
    
     mymodel = MyModel()
     mymodel.save(user=request.user)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a side project to build a new web app idea of
I have an idea for an app that I would like to build which
I have got idea of how to build a website in 2 languages, i
I'm trying to build my own template tags. I have no idea why I
I would like to build a mobile app, brewed from nothing more but html/css
I'm looking to build a web interface for an existing Ruby app and I'm
I have an idea for a large web application, which in my mind would
I really have no idea how to ask this, so with that have no
I am just investigating the idea of this so have no example code. I've
I have an application that sends messages to an external web service. I build

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.