Closed derdem closed 5 years ago
I think this is happening because RegistrationForm
inherits from UserCreationForm
without overriding UserCreationForm.Meta.model
which just uses the default User
model rather than the result of get_user_model
. See:
If I set model = get_user_model()
or similar in RegistrationForm.Meta
it seems to fix things.
Yeah, the tests aren't really written to be able to run in a project with a custom user model, since doing so always requires a custom RegistrationForm
subclass.
I'm not sure how to fix that, or whether it should be fixed; the tests for django-registration aren't supposed to even be installed by the package, let alone run as part of a project's test suite. And the fact that RegistrationForm
breaks in the presence of a custom user model is a deliberate decision to make sure people have to read the custom-user documentation and do what it says.
Since this seems to be due to a working-as-designed issue (you're supposed to be forced to write your own subclass, and django-registration's tests aren't meant to be run as part of a project using a custom user model), I'm closing this.
Hey,
When I run the registration unittests I receive quite often the following error:
Traceback (most recent call last): File "/srv/igp/frontend/base/registration/tests/base.py", line 96, in assertSignalSent yield cm File "/srv/igp/frontend/base/registration/tests/base.py", line 197, in test_registration_signal data=self.valid_data File "/usr/local/lib/python3.5/dist-packages/django/test/client.py", line 525, in post response = super().post(path, data=data, content_type=content_type, secure=secure, **extra) File "/usr/local/lib/python3.5/dist-packages/django/test/client.py", line 341, in post secure=secure, **extra) AttributeError: Manager isn't available; 'auth.User' has been swapped for 'users.CustomUser'
This happens whenever the client calls the 'registration_register' url. I already looked for a case where from django.contrib.auth import User instead of from django.contrib.auth import get_user_model is called, but couldn't find any instance.
Apart of that I don't know what might cause the User mixup.
Happy for any helpful hint.
Cheers, Niko