Hi Adam,
It's pretty inefficient, but you can do:
MyModel.objects.filter(pk__in=[obj.pk for obj in MyModel.objects.all() if
user.has_perm('read', obj)])
But, actually, I think you want to use get_objects_for_user():
http://django-guardian.readthedocs.org/en/v1.2/userguide/check.html#get-objects-for-user
Collin
On Tuesday, March 10, 2015 at 5:47:57 PM UTC-4, Adam Gamble wrote:
>
> Hi all,
>
> I'm stuck on how to restructure the following in order to return a
> QuerySet instead of a List (needed for Lazy evaluation):
>
> filter(lambda o: user.has_perm('read', o), MyModel.objects.all())
>
> Using django-guardian <http://django-guardian.readthedocs.org>, for
> object-level permissions.
>
> Appreciate any ideas,
>
> Adam
>
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/d4e2e9f4-941d-4cf9-b77e-b7a2bacb54fb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.