#22865: Testing framework: ValueError: Cannot create form field for 'user' yet,
because its related model 'myauth.User' has not been loaded yet
-----------------------------------+--------------------------------------
     Reporter:  jdufresne          |                    Owner:  nobody
         Type:  Bug                |                   Status:  new
    Component:  Testing framework  |                  Version:  1.6
     Severity:  Normal             |               Resolution:
     Keywords:                     |             Triage Stage:  Unreviewed
    Has patch:  0                  |      Needs documentation:  0
  Needs tests:  0                  |  Patch needs improvement:  0
Easy pickings:  0                  |                    UI/UX:  0
-----------------------------------+--------------------------------------

Comment (by jdufresne):

 Replying to [comment:2 timo]:
 > I believe you need to have `django.contrib.auth` in `INSTALLED_APPS` in
 order to use `from django.contrib.auth.models import AbstractBaseUser`.

 This appears to contradict actual behavior I've discovered from testing. I
 purposely do not include `contrib.auth` in my actual application because I
 don't want any auth models (groups, permissions, etc.). I stub the actual
 `User.get_*` functions required by `contrib.admin` to avoid requiring
 them.

 This works 100% when running the actual site, but creates the above import
 issue when running tests. The workaround provided above allows the User
 model to load, and at that point, tests run 100% fine. So it seems, this
 can work perfectly fine so long as `AUTH_USER_MODEL` is loaded ahead of
 time at some point.

 Adding `contrib.auth` to my `INSTALLED_APPS` would do nothing for me other
 than creating a bunch of unused tables.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/22865#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.8b83cdb0dcb76813faa025cd1db9978a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to