我正在尝试使用“数组模型字段”(djongo)添加数据,如图所示Djongo 文档(数组模型字段)或
from djongo import models
class Blog(models.Model):
name = models.CharField(max_length=100)
tagline = models.TextField()
class Meta:
abstract = True
class MetaData(models.Model):
pub_date = models.DateField()
mod_date = models.DateField()
n_pingbacks = models.IntegerField()
rating = models.IntegerField()
class Meta:
abstract = True
class Author(models.Model):
name = models.CharField(max_length=200)
email = models.EmailField()
class Meta:
abstract = True
def __str__(self):
return self.name
class Entry(models.Model):
blog = models.EmbeddedModelField(
model_container=Blog,
)
meta_data = models.EmbeddedModelField(
model_container=MetaData,
)
headline = models.CharField(max_length=255)
body_text = models.TextField()
authors = models.ArrayModelField(
model_container=Author,
)
n_comments = models.IntegerField()
def __str__(self):
return self.headline
在 admin.py 中,我添加了用于在管理面板中注册模型
from django.contrib import admin
from .models import Entry
admin.site.register(Entry)
当我尝试通过http://localhost:8000/admin/添加数据时,我遇到了 MigrationError ...
我的错误在哪里?我不明白什么?