Hi Thiago, I have believe MyListView is a subclass of ListView. The cleaner way to do what you are trying to achieve will be to override the get_queryset() method.
The code you gave is not working because pk will not be available when python starts to evaluate your urls.py file. pk becomes 'alive' when the regexp is evaluated. You can have something like this: url(r'^groups/(?P<pk>\d+)/$', login_required(MyListView.as_view(model=Person, )), name='person_group_list'), and then override get_queryset: def get_queryset(self): queryset = super(MyListView, self).get_queryset() pk = self.kwargs.get('pk') return queryset.filter(groups__id=pk) Sent from my Windows Phone ------------------------------ From: Thiago Carvalho D' Ávila Sent: 2/9/2013 12:23 PM To: Django Users Subject: Doubt in urls.py filter Hello Guys, The problem I have is that I want to use a view (rather not modifing it) to show all person in a group. The problem is I don't know how to use the pk in the regex to filter in the same line... I wanted something like: url(r'^groups/(?P<pk>\d+)/$', login_required(MyListView.as_view(model=Person, queryset=Person.objects.filter(groups__id=pk))), name='person_group_list'), With this I get: NameError at /clientes/ name 'pk' is not defined Any hint? -- 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 django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out. -- 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 django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.