Created
August 23, 2012 14:06
-
-
Save gilsondev/3436971 to your computer and use it in GitHub Desktop.
Alterando atributos de certos fields da classe Pai
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
class User(models.Model): | |
""" | |
Users within the Django authentication system are represented by this | |
model. | |
Username and password are required. Other fields are optional. | |
""" | |
username = models.CharField(_('username'), max_length=30, unique=True, | |
help_text=_('Required. 30 characters or fewer. Letters, numbers and ' | |
'@/./+/-/_ characters')) | |
first_name = models.CharField(_('first name'), max_length=30, blank=True) | |
last_name = models.CharField(_('last name'), max_length=30, blank=True) | |
email = models.EmailField(_('e-mail address'), blank=True) | |
password = models.CharField(_('password'), max_length=128) | |
is_staff = models.BooleanField(_('staff status'), default=False, | |
help_text=_('Designates whether the user can log into this admin ' | |
'site.')) | |
is_active = models.BooleanField(_('active'), default=True, | |
help_text=_('Designates whether this user should be treated as ' | |
'active. Unselect this instead of deleting accounts.')) | |
is_superuser = models.BooleanField(_('superuser status'), default=False, | |
help_text=_('Designates that this user has all permissions without ' | |
'explicitly assigning them.')) | |
last_login = models.DateTimeField(_('last login'), default=timezone.now) | |
date_joined = models.DateTimeField(_('date joined'), default=timezone.now) | |
groups = models.ManyToManyField(Group, verbose_name=_('groups'), | |
blank=True, help_text=_('The groups this user belongs to. A user will ' | |
'get all permissions granted to each of ' | |
'his/her group.')) | |
user_permissions = models.ManyToManyField(Permission, | |
verbose_name=_('user permissions'), blank=True, | |
help_text='Specific permissions for this user.') | |
objects = UserManager() | |
class Meta: | |
verbose_name = _('user') | |
verbose_name_plural = _('users') | |
# ... |
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
# -*- coding: utf8 -*- | |
from django.contrib.auth.models import User | |
class Other(User): | |
"""Fonte: | |
http://stackoverflow.com/questions/4904230/django-change-default-value-for-an-extended-model-class | |
""" | |
# other fields | |
def __init__(self, *args, **kwargs): | |
self._meta.get_fields('username').max_length=100 | |
super(Other, self).__init(*args, **kwargs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment