Created
November 24, 2012 08:01
-
-
Save bmispelon/4138833 to your computer and use it in GitHub Desktop.
UserCreationForm issues with custom user model
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.contrib.auth.forms import UserCreationForm | |
| class SignupForm(UserCreationForm): | |
| pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| >>> from myapp.forms import SignupForm | |
| >>> f = SignupForm({'username': 'foo', 'password1': 'bar', 'password2': 'bar'}) | |
| >>> f.is_valid() | |
| Traceback (most recent call last): | |
| File "<console>", line 1, in <module> | |
| File "/path/to/my/venv/lib/python2.7/site-packages/django/forms/forms.py", line 126, in is_valid | |
| return self.is_bound and not bool(self.errors) | |
| File "/path/to/my/venv/lib/python2.7/site-packages/django/forms/forms.py", line 117, in _get_errors | |
| self.full_clean() | |
| File "/path/to/my/venv/lib/python2.7/site-packages/django/forms/forms.py", line 272, in full_clean | |
| self._clean_fields() | |
| File "/path/to/my/venv/lib/python2.7/site-packages/django/forms/forms.py", line 290, in _clean_fields | |
| value = getattr(self, 'clean_%s' % name)() | |
| File "/path/to/my/venv/lib/python2.7/site-packages/django/contrib/auth/forms.py", line 87, in clean_username | |
| User.objects.get(username=username) | |
| File "/path/to/my/venv/lib/python2.7/site-packages/django/db/models/manager.py", line 256, in __get__ | |
| self.model._meta.object_name, self.model._meta.swapped | |
| AttributeError: Manager isn't available; User has been swapped for 'myapp.User' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.contrib.auth.models import AbstractUser | |
| class User(AbstractUser): | |
| pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| AUTH_USER_MODEL = 'myapp.User' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment