> articles = [article for article in
> Article.objects.all().select_related('permission') if
> article.permission.can_view_article(request.user)]
The only problem I see is that is that 'articles' is a list, not a
queryset. The reason I was using q.exclude(pk=item.pk) is because the
return value
> Everytime you call exclude (btw, this should be q =
> q.exclude(pk=item.pk), no?),
Yes =) I wrote that quickly with my post.
> articles = [article for article in
> Article.objects.all().select_related('permission') if
> article.permission.can_view_article(request.user)]
Good idea.
--
You r
On Sat, Jul 3, 2010 at 7:20 PM, Wiiboy wrote:
> Is there a way to filter based on the result of a model instance
> method?
>
> I've got a Permission model with a one-to-one relationship with an
> Article. The Permission model stores the different groups that the
> Article author said could read t
As stated there is no way to filter on any non-field attribute,
property or method.
However, don't despair. If the result of your permission check can be
expressed as another Django query then it should be possible to
construct something in the ORM that uses this. That said, we have had
trouble wi
> As I understand it, parameters passed to filter() are translated into SQL
> statements. An arbitrary python method that you write for your object can
> do any number of things, which might not be translatable into SQL. So I
> don't see how any "filter on the result of any method" feature would
Perhaps someone with much more Django experience will correct me, but I am
99% sure that this is impossible.
As I understand it, parameters passed to filter() are translated into SQL
statements. An arbitrary python method that you write for your object can
do any number of things, which might not
Anyone?
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this gr
7 matches
Mail list logo