Testing: @override_settings(AUTH_USER_MODEL='auth.User') no working.

130 views
Skip to first unread message

Serge G. Spaolonzi

unread,
Sep 29, 2013, 7:27:50 PM9/29/13
to django...@googlegroups.com
Hi,

I am failing to override the AUTH_USER_MODEL settings for a unittest, it throws:

"Manager isn't available; User has been swapped for 'None'"

Is it possible to override AUTH_USER_MODEL in the unittest?
My goal is to use the default user model provided by django for the test only.

Thanks

--
Serge G. Spaolonzi
Cobalys Systems
http://www.cobalys.com

Russell Keith-Magee

unread,
Sep 29, 2013, 8:09:30 PM9/29/13
to Django Users
On Mon, Sep 30, 2013 at 7:27 AM, Serge G. Spaolonzi <se...@cobalys.com> wrote:
Hi,

I am failing to override the AUTH_USER_MODEL settings for a unittest, it throws:

"Manager isn't available; User has been swapped for 'None'"

Is it possible to override AUTH_USER_MODEL in the unittest?
My goal is to use the default user model provided by django for the test only.
 
Yes, it is possible. That's why the approach is documented:


If you're getting an error, It sounds like something else is going wrong in your test suite -- my guess would be that you haven't got the auth app in INSTALLED_APPS. However, it's impossible to say for sure without seeing more code.

Yours,
Russ Magee %-)

Serge G. Spaolonzi

unread,
Sep 30, 2013, 10:42:29 PM9/30/13
to django...@googlegroups.com
Thanks, it worked.
Changing @override_settings(AUTH_USER_MODEL='auth.User') for
@override_settings(AUTH_USER_MODEL='auth.CustomUser') made the trick.
> --
> 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 http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
Reply all
Reply to author
Forward
0 new messages