0

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?

1 Answer 1

3

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.

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

4 Comments

Thanks! I ended up deleting all my migrations and everything worked!
@waterAddict Glad to help. Do you need any more help with this question? If this answer solved your problem please mark it as accepted by clicking the check mark next to the answer.
Any chance you could explain why this fixes the problem?
@Collin There were issues with swappable_dependency in django 1.7 alpha. I don't know if things are fixed now. It is explained here. Basically: "the issue is that swappable_dependency resolves to app_label.first, which doesn't make a lot of sense when the app with the migrations is itself being migrated"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.