我如何才能超越关系经理?例如:
user.entry_set # django.db.models.fields.related.RelatedManager
但我需要自己的经理。我尝试这段代码,但这不起作用:
class EntryManager(models.Manager):
use_for_related_fields = True
Thanks.
您的任务需要相当棘手的代码,这将很难维护和理解(如果可能的话)。
那这个呢?
class EntryManager(models.Manager):
def by_user(self, user):
# do anything you want
# usage
Entry.objects.by_user(user=user)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)