Re: When to use get_user_model()

2018-02-20 Thread Scot Hacker
It's good future-proofing, in case you ever change the User model in your project. In real life, that's highly unlikely, but where it's *really important* to use get_user_model() is when you are writing reusable apps for distribution. If your app is intended to be dropped into any existing Djan

Re: When to use get_user_model()

2018-02-19 Thread tango ward
orms.py, does it mean it will use the RegUser class from >> the models.py? Sorry, I am confuse. >> >> On Sun, Feb 18, 2018 at 9:41 PM, Mukul Agrawal wrote: >> >>> The answer on this link can also help you in why and when to use >>> get_user_model(). >

Re: When to use get_user_model()

2018-02-18 Thread Xavier Paniello
: > > @Mukul Agrawal, > > thanks, i'll read this. > > > @Xavier, > > the model in forms.py, does it mean it will use the RegUser class from the > models.py? Sorry, I am confuse. > > On Sun, Feb 18, 2018 at 9:41 PM, Mukul Agrawal > wrote: > >> The ans

Re: When to use get_user_model()

2018-02-18 Thread tango ward
@Mukul Agrawal, thanks, i'll read this. @Xavier, the model in forms.py, does it mean it will use the RegUser class from the models.py? Sorry, I am confuse. On Sun, Feb 18, 2018 at 9:41 PM, Mukul Agrawal wrote: > The answer on this link can also help you in why and whe

Re: When to use get_user_model()

2018-02-18 Thread Mukul Agrawal
The answer on this link can also help you in why and when to use get_user_model(). https://stackoverflow.com/questions/24629705/django-using-get-user-model-vs-settings-auth-user-model On Feb 18, 2018 4:11 AM, "tango ward" wrote: Hi, I am playing around with user registration. I cam

Re: When to use get_user_model()

2018-02-18 Thread Xavier Paniello
Hi tangoward15, The User model by default is auth.User, but you can define a custom one and reference it at settings: https://docs.djangoproject.com/en/2.0/ref/settings/#auth-user-model So, get_user_model() will return the model defined at AUTH_USER_MODEL setting. Salut! El dissabte, 17 febr

Re: When to use get_user_model()

2018-02-17 Thread tango ward
I also checked the documentation of it but I am confuse. It says "Instead of referring to User directly, you should reference the user model using django.contrib.auth.get_user_model(). This method will return

When to use get_user_model()

2018-02-17 Thread tango ward
Hi, I am playing around with user registration. I came across a code where the get_user_model() was assigned to a model in Meta class inside a form. I was just wondering, what is the benefit of using the get_user_model() as Model in a form instead of importing a class from models.py then use that