Django/Python: Update the relation to point at settings.AUTH_USER_MODEL
Asked Answered
O

2

11

I'm completely new to Python and Django, but I need to install testbedserver-software (for which I follow this tutorial) on my server. Now I'm running into trouble when running following command:

python manage.py syncdb

The following error is shown:

CommandError: One or more models did not validate:
menu.bookmark: 'user' defines a relation with the model 'auth.User', which has been swapped out. Update the relation to point at settings.AUTH_USER_MODEL.
dashboard.dashboardpreferences: 'user' defines a relation with the model 'auth.User', which has been swapped out. Update the relation to point at settings.AUTH_USER_MODEL.

This is my manage.py:

#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "controller.settings")

    from django.core.management import execute_from_command_line

    execute_from_command_line(sys.argv)

This is my settings.py:

from controller.settings_example import *

# Probably you want to override at least the database configuration:
DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.postgresql_psycopg2',
    'NAME': 'controller',
    'USER': 'confine',
    'PASSWORD': 'confine',
    'HOST': 'localhost',
    'PORT': '',
}
}

I already found this http://grokbase.com/p/gg/django-users/12ar0b12ca/ver-1-5-specifying-custom-user-model-extends-abstractuser-doesnt-work. But I don't even know where to apply the solution. (I don't even know this problem is PostgreSQL, Python or Django based...)

Can someone help me with this?

Thanks in advance, atobi

Octahedral answered 8/1, 2013 at 13:26 Comment(5)
is there nothing else in settings? Django seems to think that you have set AUTH_USER_MODEL. oh and what version of Django is this?Clerical
It sounds like you have settings for Django <=1.4 but are running 1.5 I would suggest running: import django django.VERSION To see what version it is you are using.Crafton
@JoeDoherty: django version (1, 6, 0, 'alpha', 0) so I guess 1.6?Octahedral
@scytale: Sorry, yes, it seems to import settings_example.py and that contains this: pastebin.com/DgNQsq1MOctahedral
Have a look at the models which it is talking about in the error. There maybe a specific reference to something like user = ForeignKey(). I have not used 1.5 yet so I may be a bit offCrafton
C
14

in settings_example.py you have AUTH_USER_MODEL = 'users.User'. However you are using an app - menu.bookmark - that has a relation to django.contrib.auth.User - you can't have both. Setting AUTH_USER_MODEL means that you are replacing the built-in Django user model with your own. See http://procrastinatingdev.com/django/using-configurable-user-models-in-django-1-5/ for details.

Clerical answered 9/1, 2013 at 15:48 Comment(0)
L
0

This Error might because u are importing your User model like this

from django.contrib.auth.models import User

at the top of a model file after adding this AUTH_USER_MODEL = 'users.User' to the settings.py

you want to remove this import... from django.contrib.auth.models import User

Lashaunda answered 20/6 at 11:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.