Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from supercodepoet/master
Another option for updating the code for Django 1.5 custom user model
- Loading branch information
Showing
11 changed files
with
93 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
*.egg-info | ||
*.sql | ||
docs/build/* | ||
.DS_Store |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[ | ||
{ | ||
"pk": 1, | ||
"model": "users.user", | ||
"fields": { | ||
"first_name": "Jez", | ||
"last_name": "Dez", | ||
"is_active": true, | ||
"is_superuser": false, | ||
"is_staff": false, | ||
"last_login": "2009-11-02 03:06:19", | ||
"groups": [], | ||
"user_permissions": [], | ||
"password": "", | ||
"email": "jezdez@github.com", | ||
"date_joined": "2009-11-02 03:06:19", | ||
"greeting_message": "Hello customer user model" | ||
} | ||
} | ||
] |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from django.contrib import auth | ||
|
||
|
||
def get_user_class(): | ||
if hasattr(auth, "get_user_model"): | ||
return auth.get_user_model() | ||
else: | ||
return auth.models.User | ||
|
||
|
||
User = get_user_class() |
This file contains 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
Empty file.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.contrib.auth.admin import UserAdmin | ||
from example.users.User | ||
|
||
|
||
admin.site.register(User, UserAdmin) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin | ||
from django.db import models | ||
from django.utils import timezone | ||
|
||
|
||
class User(AbstractBaseUser, PermissionsMixin): | ||
USERNAME_FIELD = 'email' | ||
REQUIRED_FIELDS = ['first_name', 'last_name'] | ||
|
||
first_name = models.CharField(max_length=50) | ||
last_name = models.CharField(max_length=50) | ||
email = models.EmailField(unique=True) | ||
greeting_message = models.TextField() | ||
is_staff = models.BooleanField(default=False) | ||
is_active = models.BooleanField(default=True) | ||
date_joined = models.DateTimeField(default=timezone.now) |