2👍
✅
You really need to write a view. That’s the advantage of class based views, you can simply inherit from MyListView. (I know you said you didn’t want to do this, but it really is the right way to go).
from your_app.views import MyListView
from your_app.models import Person
class MySpecialListView(MyListView):
model = Person
get_queryset(self, *args, **kwargs):
return Person.objects.filter(groups__id=self.kwargs['group_pk']))
As a side note, I would change pk to group_pk in your regex to avoid any possible conflicts.
url(r'^groups/(?P<group_pk>\d+)/$', login_required(MySpecialListView.as_view(), name='person_group_list')
Source:stackexchange.com