morlandi / django-ajax-datatable

A Django app which provides the integration of a Django project with the jQuery Javascript library DataTables.net
MIT License
204 stars 64 forks source link

Pass *args **kwargs to get_initial_queryset() #50

Closed LukeWebbJacobs closed 2 years ago

LukeWebbJacobs commented 2 years ago

Hi, I had to monkey patch get like this:

def get(self, request, *args, **kwargs):
    self.milestone = kwargs['milestone']
    return super(TaskListInProgAPI, self).get(request, *args, **kwargs)

so that I could read my url paramters. We could pass these directly to get_initial_queryset()? Is there another way to use these when overriding get_initial_queryset()?

etiennepouliot commented 2 years ago

Try this :

def get_initial_queryset(self, request=None):
    milestone = request.resolver_match.kwargs['milestone']
    ...
LukeWebbJacobs commented 2 years ago

Awesome thank you, that works great. Basic django knowledge lacking here sorry!