KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm trying to set up my custom user model in Django. The reason is that I want to use email as the username, and remove the username field entirely. I've run into a error, that I just can't figure out. Manager isn't available; User has been swapped for 'app.MyUser' Exception Location: .../django/db/models/manager.py in __get__, line 256 Python Version: 2.7.3 Python Path: [...project specific files, '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/PIL', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7', '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode'] I've googled like crazy, but haven't found too many pages about this error message. I have found some pages, with suggestions on how to solve it, but none of the suggestions have worked for me. My code: I've set the custom user model. I have declared the custom user model AUTH_USER_MODEL = 'app.MyUser' in settings.py. I have also set up a custom UserManager: class MyUserManager(BaseUserManager): def create_user(self, email, password=None): """ Creates and saves a User with the given email. Note that none of the optional fields gets values in the creation. These fields will have to be filled out later on. """ if not email: raise ValueError('Users must have an email address') user = self.model(email=MyUserManager.normalize_email(email)) user.set_password(password) user.save(using=self._db) return user def create_superuser(self, email, password=None): """ Creates and saves a superuser with the the above mentioned attributes """ user = self.create_user(email, password=password)
Tags (comma-separated)
Save Edits
Cancel