python - 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 表。
有谁知道我该怎么办?或者可以看到错误、知道提示或其他帮助方式?
解决方案
这个问题似乎与迁移不起作用无关。
迁移不会使模型出现在管理员中。为此,您需要注册您的模型。
推荐阅读
- sql - 使用 SQL/Impala 在一段时间内滚动总和
- python-3.x - 使用 Jedi 的 Spyder 4 代码自动完成在编辑器中(仍然)很慢
- python - scipy 和 excel 结果在 T 分布中不同
- java - 对新的对应对象使用 Java 多态性(StringBuffer 或 StringBuilder)
- javascript - 在 MOBILE 上将其他人推开的可拖动元素
- c++ - 静态大小的 Rcpp 空列表会比 list.push_back() 更有效吗?
- angular - 角度 8 秒表
- python - 烧瓶测试路线'/'
- unreal-engine4 - 如何从游戏视图访问小部件的蓝图
- r - 如何计算> 1000列的数据集中每列有多少条目?