1

I extend the Django user model like this:

#core.models class Institute(models.Model): phone_regex = RegexValidator(regex=r'^\+?1?\d{9,15}$', message=institute_phone_help_text) name = models.CharField(_('name'), max_length=255) description = models.TextField(_('description'), blank=True) abbreviation = models.CharField(_('abbreviation'), blank=True, max_length=100) address = models.TextField(_('address'), blank=True) phone = models.CharField(validators=[phone_regex], max_length=17, blank=True) # validators should be a list websites = ArrayField(models.URLField(max_length=255), verbose_name=_('websites'), blank=True, null=True) class Meta: verbose_name = _('institute') verbose_name_plural = _('institutes') def __str__(self): return '{0} ({1})'.format(self.name, self.abbreviation) class User(AbstractUser): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) institute = models.ForeignKey(Institute, on_delete=models.CASCADE) params = JSONField(_('params'), null=True, blank=True,) about_me = models.TextField(_('about me'), blank=True,) 

With an empty DB each time that I launch ./manage.py makemigrations core it creates always a new migration file

import django.contrib.auth.models from django.db import migrations class Migration(migrations.Migration): dependencies = [ ('core', '0002_auto_20190430_1655'), ] operations = [ migrations.AlterModelManagers( name='user', managers=[ ('objects', django.contrib.auth.models.UserManager()), ], ), ] 

I tried different combinations:

./manage.py makemigrations core ./manage.py migrate core ./manage.py migrate ./manage.py makemigrations core ./manage.py makemigrations core ./manage.py makemigrations ./manage.py migrate 

It always creates the migration file.

Thanks.

D

7
  • Is it create multiple migrations files? Commented Apr 30, 2019 at 15:10
  • @shafik yes it does each time I run it. Commented Apr 30, 2019 at 15:12
  • When you run makemigrations Do you see this No changes detected Commented Apr 30, 2019 at 15:17
  • why is this an issue? is it then creating the same migration again or what? Commented Apr 30, 2019 at 16:38
  • if you can, i would start from scratch again (including creating the first migrations). Commented Apr 30, 2019 at 17:02

1 Answer 1

1

if you use AbstractUser model make sure you run makemigrations before migrate.

i had same issue with AbstractUser, I solved it by deleting the sqlite3 file also all migrations files. After that i run this two commands :

python manage.py makemigrations python manage.py migrate 

inside your terminal

Let me know if that help!

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.