Thanks Xavier
On Mon, Feb 19, 2018 at 1:02 PM, Xavier Paniello <pezbaloo@gmail.com> wrote:
Hi tangoward15,--
Django will use auth.User as the user model in the system, unless you change AUTH_USER_MODEL = RegUser in settings.py
Be carefull, to change the user model has some particularities you can read in docs (warning section):
https://docs.djangoproject.com/en/2.0/ref/settings/#auth- user-model
Other option to extend auth.User is a model with a one2one field related to auth.User, or a proxy model:
https://simpleisbetterthancomplex.com/ tutorial/2016/07/22/how-to- extend-django-user-model.html
Salut!
El diumenge, 18 febrer de 2018 15:23:53 UTC+1, tangoward15 va escriure:the model in forms.py, does it mean it will use the RegUser class from the models.py? Sorry, I am confuse.@Xavier,@Mukul Agrawal,thanks, i'll read this.On Sun, Feb 18, 2018 at 9:41 PM, Mukul Agrawal <amuk...@gmail.com> wrote:--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" <tango...@gmail.com> wrote:--JarvisThanks,forms.pymodels.pyI 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 class as model of the form and when should I use it?Hi,
class RegUser(User):
def __str__(self):
return self.username
class UserCreateForm(UserCreationForm):
class Meta:
fields = ('username', 'password1', 'password2')
model = get_user_model()
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com .
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users .
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAA6wQL%2Bq1k .Q7ukjtE3gV64iu9y2SXdgojZXBF3R4 6BCuTN0xoA%40mail.gmail.com
For more options, visit https://groups.google.com/d/optout .
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com .
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users .
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CACRd7haky8% .2BY7%2BNDHNFV3EbiSxBU4B65CJUSF 7v3mXb3%3DP8D%2BA%40mail. gmail.com
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com .
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users .
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/226fceca- .eb59-49c8-9606-b869f0c25feb% 40googlegroups.com
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAA6wQLKZoFWbg_67wtA%3DhFpPKu8OKo%3DCWZw-Baq6Wf%3D%2BZoNXcQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment