Tags: django,clases

Sort by: Date / Title /

  1. 8 years ago by macks
    1. #1
    2. from django.db import models
    3. from django.contrib.auth.models import User, UserManager
    4.  
    5. class CustomUser(User):
    6.     birthday = models.DateField()
    7.     activation_key = models.CharField(max_length=255, blank=True, default='')
    8.     photo_url = models.CharField(max_length=50, blank=True) # cant incrementada de votaciones
    9.     User._meta.get_field('username')._unique = False
    10.     User._meta.get_field('email')._unique = True
    11.     User._meta.get_field_by_name('username')[0].max_length=75
    12.  
    13. #2 save child class
    14. from users.models import CustomUser
    15. def saveCustomUsers(request):
    16.     usr = CustomUser()
    17.     usr.username = 'macks'
    18.     usr.password = '123456'
    19.     usr.activation_key = 'sfsdf123456'
    20.     usr.birthday = datetime.now()
    21.     usr.photo_url = 'image.jpg'
    22.     usr.save()
    Paste this in your website: <script type="text/javascript" src="http://www.posteet.com/embed/2083"></script>

First / Previous / Next / Last / Page 1 of 1 (1 posteets)