当我尝试在命令行中运行python manage.py makemigrations
ERRORS:
asking.Question: (models.E020) The 'Question.check()' class method is currently overridden by <function BaseManager.check at 0x7f0f104889d8>.
这是[{1}}中的Question
课程:
models.py
这是BaseModel类:
class Question(BaseModel):
content = models.CharField(max_length=250)
answer = models.TextField("answer", blank=True, null=True)
answerer = models.ForeignKey(
User,
on_delete=models.CASCADE,
related_name="questions"
)
def __str__(self):
return self.content
我正在使用Django 2.0.5版
答案 0 :(得分:1)
我认为问题是您的BaseModel
来自SoftDeletableManager
而不是SoftDeletableModel
。
例如改为:
class BaseModel(SoftDeletableModel, TimeStampedModel, models.Model):
class Meta:
abstract = True
答案 1 :(得分:0)
应将经理设置为模型属性
from django.db import models
from model_utils.models import SoftDeletableManager, TimeStampedModel
class BaseModel(TimeStampedModel, models.Model):
objects = SoftDeletableManager()
class Meta:
abstract = True