首页 > 解决方案 > django中迁移不起作用怎么办?

问题描述

我在 Django 中创建模型时遇到问题。我想创建新模型,所以我编写代码:

class Image(models.Model):
    title = models.CharField(max_length=100)
    image = models.ImageField()

在下一步中,我做了python manage.py makemigrations, python manage.py migrate。我得到了这个结果:

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
    ('myfirstapp', '0008_delete_image'),
]

operations = [
    migrations.CreateModel(
        name='Image',
        fields=[
            ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
            ('title', models.CharField(max_length=100)),
            ('image', models.ImageField(upload_to='')),
        ],
    ),
]

但我无权访问 Django 管理中的 Image 表。

有谁知道我该怎么办?或者可以看到错误、知道提示或其他帮助方式?

标签: pythondjangomigratemakemigrations

解决方案


这个问题似乎与迁移不起作用无关。

迁移不会使模型出现在管理员中。为此,您需要注册您的模型


推荐阅读