ValueError: Related model u'app.model' cannot be resolved

后端 未结 6 796
甜味超标
甜味超标 2020-12-29 02:06

I have two applications (ook and eek say) and I want to use a foreign key to a model in ook from a model in eek. Both are

6条回答
  •  独厮守ぢ
    2020-12-29 02:11

    I have found that it looks like this bug was not fixed yet when you scroll down to the bottom.

    Django ValueError: Related model cannot be resolved Bug

    I am using 1.11.7, they are talking about 1.9.3.

    It worked everything on localhost, but was always failing on Heroku, so I tested all the options/answers above and nothing worked.

    Then I have noticed, localhost DB in Admin I had 1 profile created (1 DB record), went to Heroku and DB has 0 records for Profile table so I have added 1, pushed the migration, python manage.py migrate and all it went OK.

    That validates that I did not need to change any of those migrations manually that all is working.

    Maybe it will help to someone.

    migrations

    # -*- coding: utf-8 -*-
    # Generated by Django 1.11.7 on 2017-11-23 21:26
    from __future__ import unicode_literals
    
    from django.db import migrations, models
    import django.db.models.deletion
    
    
    class Migration(migrations.Migration):
    
        dependencies = [
             ('blog', '0005_blog_author'),
        ]
    
        operations = [
            migrations.AlterField(
                 model_name='blog',
                 name='author',
    
    field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, 
    to='core.Profile'),
            ),
        ]
    

提交回复
热议问题