Hey David,

Could you try explicitly defining an objects manager on your User model and 
see it if helps.

e.g.

from django.contrib.auth.models import UserManager

class User(AbstractUser):
    ... # fields
    objects = UserManager()

I'm also having trouble reproducing locally though.

Simon

Le jeudi 2 mai 2019 05:17:33 UTC-4, Daviddd a écrit :
>
> Dear All,
>
> Empty DB, no migration is applied, I have a core app like:
>
> #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,)
>
> The app core is in the INSTALLED_APPS. 
>
> If I run
> ./manage.py migrate
>
> it correctly says that is not finding the core app, hence I run
> ./manage.py makemigrations core
>
> It creates the migration file 001_initial*.
>
> Now I run ./manage.py migrate and it works great,
>
> But if I continue to run ./manage.py makemigrations it continues to add N 
> core app migration file like:
>
> # Generated by Django 2.2.1 on 2019-05-02 08:55
>
> import django.contrib.auth.models
> from django.db import migrations
>
>
> class Migration(migrations.Migration):
>     dependencies = [
>         ('core', '0001_initial'),
>     ]
>
>     operations = [
>         migrations.AlterModelManagers(
>             name='user',
>             managers=[
>                 ('objects', django.contrib.auth.models.UserManager()),
>             ],
>         ),
>     ]
>
>
>
> I tried various combinations but none worked:
>
> ./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
>
>
>
>
> Linked to this question:
>
> https://stackoverflow.com/questions/55923797/django-2-2-abstractuser-and-migration-issue
>
> Is it a bug?
> How can I solve this?
>
> Thanks.
>
> D
>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4507eecf-b700-4e58-b5ae-e54b3ad6a3c0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to