0

I am trying to use Cookiecutter to help me to deploy a web app with Heroku and Amazon S3.

This is an app that I developed locally without Cookiecutter so I am copy-pasting the files into the new project and debug step by step.

The original app used the build-in Django User Model so I would like to switch to the Abstract User Model that comes with Cookiecutter. I started to create a new database for this project to start from scratch.

Then I thought it would be as simple as replacing User by AUTH_USER_MODEL

models.py

from config.settings.base import AUTH_USER_MODEL

class Category(models.Model):
    name = models.CharField(max_length=30)
    description = models.CharField(max_length=140,blank=True,null=True)
    date_created = models.DateField(default=timezone.now)
    date_updated = models.DateField(auto_now=True)
    created_by = models.ForeignKey(AUTH_USER_MODEL, related_name="categories")

    def __str__(self):
        return self.name

I get this error when running manage.py migrate

accounts.User.user_ptr: (fields.E301) Field defines a relation with the model 'auth.User', which has been swapped out.
    HINT: Update the relation to point at 'settings.AUTH_USER_MODEL'

In settings.py

AUTH_USER_MODEL = 'users.User'

Where I am missing something ?

Yannick
  • 1,550
  • 4
  • 18
  • 27

1 Answers1

0

Your error message seems to indicate that the problem is coming from another model called accounts.User, but it's not included in the snippet you provide. The error shows a model in the accounts app but the setting AUTH_USER_MODEL points to a model in the users app. Are these 2 different models? Did you rename the users app as accounts but forgot to update the setting?

Bruno A.
  • 1,765
  • 16
  • 17