Note that there are some explanatory texts on larger screens.

plurals
  1. PODjango: Should I use Query Strings or clean url's to map display parameters? And how?
    primarykey
    data
    text
    <p>I have the following urlconf:</p> <pre><code>urlpatterns = patterns('page.manager.views', url(r'^$', 'pages', name='page_manager-pages'), url(r'^add/$', 'add_page', name='page_manager-add_page'), url(r'^(?P&lt;page_id&gt;\d+)/', include(object_patterns)), ) </code></pre> <p>The 'pages' view must return an object list of all pages. The user will be offered several display/search options through a side menu: - created: any/ past 6hours/12hours/24hours/week - Status: any/ status_1/status_2/status_3 - Duration: any / duration_1/duration_2/duration_3 etc.</p> <p>These options are used to select which values should be presented to the user and can be used in combination, eg: created=any, status=status_1, duration=duration_1</p> <p>My question is, how best to achieve this in Django? </p> <p>What I have so far: I can subclass a generic view for list objects, creating a view which takes the arguments(created, status, duration, etc) and provides the proper queryset(with the chosen[or default] ordering options passed along with the other arguments).</p> <p>To pass these arguments, query strings seem to be right for this, since we are selecting from a resource(the list of all pages). Yes/no?</p> <p>I'm also aware we get this information from request.GET.get('argument_name').</p> <p>But how to create the links for the search options? eg: any, any/ status_1/status_2/status_3. We need to know which are already active, so...template tag? An easier way perhaps?</p> <p>Is this the proper solution to handle this type of thing in Django, or is there a better way?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload