Question

Using the django-profiles app, I want to display the users' profiles in an ordered list. Ordered by different fields, depending on the situation.

Now the docs say something about passing extra arguments to the views here but I don't know how to do that, since the urls are just included (as opposed by defined by myself).

So,how can I pass in the "order_by" part that I can just use in the normal list view?

Was it helpful?

Solution

Checking the code [1], there is no way to alter the queryset in the way you want.

Your best option is probably to write this view yourself, using the existing implementation as a guide if you like (e.g. you can still call object_list when you've got a queryset ordered to your specification). Then either override the profile list URL in your own urls.py by declaring it first:

...
url(r'^profiles/$', path.to.my_profile_list_view, name='my_profile_list'), 

(r'^profiles/', include('profiles.urls')),
...

or create a new URL for this and use that on your site instead:

url(r'^ordered-profiles/$', path.to.my_profile_list_view, name='my_profile_list'),

[1] https://bitbucket.org/ubernostrum/django-profiles/src/c21962558420/profiles/views.py#cl-287

See also: https://bitbucket.org/ubernostrum/django-profiles/src/c21962558420/profiles/urls.py

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top