-
#1
-
from django.db import models
-
from django.contrib.auth.models import User, UserManager
-
-
class CustomUser(User):
-
birthday = models.DateField()
-
activation_key = models.CharField(max_length=255, blank=True, default=”)
-
photo_url = models.CharField(max_length=50, blank=True) # cant incrementada de votaciones
-
User._meta.get_field(‘username’)._unique = False
-
User._meta.get_field(’email’)._unique = True
-
User._meta.get_field_by_name(‘username’)[0].max_length=75
-
-
#2 save child class
-
from users.models import CustomUser
-
def saveCustomUsers(request):
-
usr = CustomUser()
-
usr.username = ‘macks’
-
usr.password = ‘123456’
-
usr.activation_key = ‘sfsdf123456’
-
usr.birthday = datetime.now()
-
usr.photo_url = ‘image.jpg’
-
usr.save()