waterAddict
waterAddict

Reputation: 1

Django User object error in models.py

I am writing my first Django project and using Django 1.7, and for my login and authentication I am using the Django User model. I am now creating my models. Project and User share a Many-to-Many relationship

models.py:

from django.db import models

from django import forms

from django.contrib.auth.models import User

class Project(models.Model):
    project_name = models.CharField(max_length=128, unique = True)
    project_description = models.CharField(max_length=128)
    users_annotating = models.ManyToManyField(User)

However, I get this error when I try to migrate:

ValueError: Related model 'auth.User' cannot be resolved

Does anyone understand this problem?

Upvotes: 0

Views: 1035

Answers (1)

mislavcimpersak
mislavcimpersak

Reputation: 3020

I'm guessing that you have

dependencies = [
    migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

in your newly created Django 1.7 migration.

If you comment out that dependency and just in case replace it with

dependencies = [
    ('auth', '__first__'),
]

things should work.

Upvotes: 3

Related Questions