小编Дми*_*нев的帖子

将项目添加到 ListAPIView

我有带有指定模型和序列化程序类的普通 ListAPIView。我需要在列表末尾添加一项。此项应手动创建(无查询集),并且应与其他项具有相同的结构。

django django-rest-framework

2
推荐指数
1
解决办法
2178
查看次数

“ ContentType”对象在数据迁移中没有属性“ model_class”

我的数据迁移文件中有此文件:

def set_target_user(apps, schema_editor):
    LogEntry = apps.get_model('auditlog', 'LogEntry')
    ContentType = apps.get_model('contenttypes', 'ContentType')
    for entry in LogEntry.objects.filter(target_user=None):
        ct = ContentType.objects.get(id=entry.content_type.id)
        model = ct.model_class()
Run Code Online (Sandbox Code Playgroud)

我提到了AttributeError。但是它在其他模块(不是migratins)中也能很好地工作。任何想法如何克服这个?

django django-migrations

1
推荐指数
1
解决办法
380
查看次数