3
作爲其中一個要求的一部分,我們重寫了自定義Queryset中的Update方法。覆蓋Django查詢集的更新方法
示例代碼如下。
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')
無法從Custom Queryset中調用基本Queryset中的更新。
類型錯誤在/輪詢/ 必須是類型,而不是PollQuerySet
任何解決方案是非常讚賞。
問題標籤爲python3所以,'超()。更新(* args,** kwargs)'。 :) – danielcorreia
對不起,忽略了,謝謝指出 – e4c5