Wednesday, February 22, 2017

Re: Bug? django.contrib.auth.forms using User model by importing from auth.models instead of get_user_model()

Fair enough, I guess subclassing it makes more sense, I saw that it uses `USERNAME_FIELD`[1] so I assumed it could use the custom model by default too, but I guess you can have completely different models and that could create some confusion.

Anyway, sorry to take you time and thanks for quick response,

On 22 February 2017 at 17:05, Davor Lučić <r.dav.lc@gmail.com> wrote:
Hello,

I have issues using custom user model and forms from contrib.auth.forms
When using `UserCreationForm` it says `auth_user table does not exists` which is expected since i have different user model.

Looking at the code, some pieces of code use `get_user_model` and `UserModel` while model forms use `User` imported from `auth.models`.

For example:

https://github.com/django/django/blob/master/django/contrib/auth/forms.py#L10

If i use UserModel there it seems to work fine. Would this be considered a bug? 
Just wanted to check before creating a ticket.

Thank you,
Davor



--
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/CAKB_9CLCd_PF-XNGnQUvU%2B%3D5pPYJgNWBFL82tk4EpuZvLB03zg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment