class MyQuerySet(models.query.QuerySet):
@property
def foo(self):
return self.filter(foo=True)
class MyManager(models.Manager):
use_for_related_field = True
def get_query_set(self):
return MyQuerySet(self.model)
class Widget(models.Model):
thingies = models.ManyToManyField(Thingy, related_name='widgets')
objects = MyManager()
When I run this query:
Thingy.objects.select_related('widgets').foo
Django tells me that
AttributeError: 'QuerySet' object has no attribute 'foo'
Is this something I should expect to work? I seem to have reached the thin edge of both documentation and discussions.
John
-- You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/Aw6O25M_gNgJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment