【发布时间】:2017-07-09 15:09:28
【问题描述】:
作为其中一项要求的一部分,我们将覆盖自定义查询集中的 Update 方法。
示例代码如下。
from django.db.models.query import QuerySet
class PollQuerySet(QuerySet):
def update(self, *args, **kwargs):
# Some Business Logic
# Call super to continue the flow -- from below line we are unable to invoke super
super(self, kwargs)
class Question(models.Model):
objects = PollQuerySet.as_manager()
question_text = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
无法从自定义查询集中调用基本查询集中的更新。
/polls/ 处的类型错误 必须是类型,而不是 PollQuerySet
非常感谢任何解决方案。
【问题讨论】:
标签: python django python-3.x django-models django-queryset