jonathanchu / django-custom-user-example Goto Github PK
View Code? Open in Web Editor NEWAn example Django project showing how to implement custom users.
License: MIT License
An example Django project showing how to implement custom users.
License: MIT License
I am virtually copying EmailUser, but just adding a field:
class CustomUser(AbstractEmailUser):
"""
Subclass EmailUser to add the last_seen date.
"""
last_seen = models.DateField(auto_now_add=True)
class Meta(AbstractEmailUser.Meta):
swappable = 'AUTH_USER_MODEL'
If I syncdb to a blank DB with AUTH_USER_MODEL = 'custom_user.EmailUser' then I am prompted for superuser no problem. But with my custom model above, no such luck. Thanks for any advice.
EDIT: I know I can call createsuperuser but I'd like to understand what I'm missing :)
Since this app is sort of generic (for newbies who just needs plug and play integration) @jonathanchu why not add test cases for the custom user model. Your take?
When I run python manage.py createsuperuser
, I got the following error:
ERRORS:
myapp.CustomUser.is_superuser: (models.E006) The field 'is_superuser' clash
es with the field 'is_superuser' from model 'myapp.customuser'.
Hey @jonathanchu I was thinking to include a more extensible example to support/show different types of users. E.g can be Account Manager, Employee and Blah blah user :P
I'm getting:
ImportError: cannot import name MAXIMUM_PASSWORD_LENGTH
from django.contrib.auth.hashers import MAXIMUM_PASSWORD_LENGTH
in your forms.py
Indeed, that variable does not seem to be defined.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.