aroooo
aroooo

Reputation: 5056

Retrieving Variable & Processing List from Tastypie URL

Let's say my override_urls is like so:

def override_urls(self):
    return [
        url(r"^(?P<resource_name>%s)/(?P<user__username>\w{4,30})%s$" % (self._meta.resource_name, trailing_slash()), self.wrap_view('dispatch_list'), name="api_dispatch_list"),
        ]

I'd like to do some custom processing owith user__username: I'd like to get all of a user's 'post' objects and combine it with everyone they follow's post objects.

How can I nab user__username for get_object_list to process? I tried to get it from the request using request.GET.get('user__username') but that didn't seem to make sense (and didn't work).

PS, is there anyway to make user__username into just username (for the sake of prettyness)?

Upvotes: 0

Views: 120

Answers (1)

Ania Warzecha
Ania Warzecha

Reputation: 1796

The user_username argument is passed in kwargs through the dispatching process not in request.GET.

You probably would want to override the get_list method and process the additional argument inside it. If you do it that way you can name your argument whatever you want and process it the way you wish.

Upvotes: 1

Related Questions