class User(AbstractBaseUser, PermissionsMixin):
SEX = (
('m', 'male'),
('f', 'female')
)
RANG = (
('b', 'beginner'),
('e', 'expert'),
('m', 'master')
)
username = models.CharField(_('username'), max_length=30, unique=True,
help_text=_('Required. 30 characters or fewer. Letters, numbers and @/./+/-/_ characters'),
validators=[
validators.RegexValidator(re.compile('^[\w.@+-]+$'), _('Enter a valid username.'), _('invalid'))
])
first_name = models.CharField(_('first name'), max_length=30, blank=True, null=True)
last_name = models.CharField(_('last name'), max_length=30, blank=True, null=True)
email = models.EmailField(_('email address'), max_length=255, unique=True)
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.'))
date_joined = models.DateTimeField(_('date joined'), default=timezone.now)
expires = models.DateTimeField(_('expiration date'), default=one_year_from_now)
age = models.IntegerField(blank=True, null=True)
sex = models.CharField(max_length=1, choices=SEX, blank=True)
native_language = models.CharField(max_length=200, blank=True)
english_proficiency = models.CharField(max_length=100, blank=True)
audio_device = models.CharField(max_length=200, blank=True)
autoplay_enabled = models.BooleanField(default=True)
USERNAME_FIELD = 'username'
REQUIRED_FIELDS = ['email', ]
objects = UserManager()
class Meta:
verbose_name = _('user')
verbose_name_plural = _('users')
def get_full_name(self):
full_name = '%s %s' % (self.first_name, self.last_name)
return full_name.strip()
def get_short_name(self):
return self.first_name
"""
def is_active(self):
return timezone.now() <= self.expires
"""
def email_user(self, subject, message, from_email=None):
send_mail(subject, message, from_email, [self.email])
I have to wonder if the name of your class is causing an overlap with the Django contrib model, which may be causing confusion with the migrations process and not catching changes (since the core contrib version doesn't have any changes).
Would it be possible to change the name of the class, even for testing?
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/01706dc6-ea01-4d1d-ab3a-692f17435ddc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You can also temporarily remove django.contrib.auth from INSTALLED_APPS when making your migrations to keep the overlap from occurring as a test, although I'm not sure if that would be possible if any other code references the contrib User model and probably isn't recommended as a production deployment strategy.
-James
So what am I doing wrong? I'm sure it's just my fault. At first I even manually edited the migrations file in the past, for example when I changed one of the fields to be mandatory instead of being optional. Old data in the database had this field still set to null, and sometimes Django asked me what to do with it but most of the time I never got it to work correctly - so again delete DB and repeat.