Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This doesn't look like sorting; this looks like a filtering issue.</p> <p>If so, you have to decide if your filtering keys are intended to be bookmarkable items, or if they're dynamic and you're meant to start from some base. The decides whether or not you're going to use URLs as your sorting keys, or CGI arguments.</p> <p>Either way, the handler is similar. For the first, you would create in your urls.py:</p> <pre><code>url('/projects/(?P&lt;status&gt;\d+)/', quote_projects), </code></pre> <p>And your projects could look like:</p> <pre><code>@login_required def quote_projects(request, status): status = dict(STATUS_CHOICES).get(status, None) if not status: raise Http404 return render_to_response( 'project/index.html', {'projects': Projects.objects.filter(status__value__exact = status)}, context_instance=RequestContext(request)) </code></pre> <p>You don't need the 'user' at all; that's provided for you automagically by the RequestContext, and is assured by the fact that you've specified this method login_required. Now you can refer to "http://example.com/projects/quoted"</p> <p>For CGI arguments, your urls.py line looks like this:</p> <pre><code>url('/projects/', quote_projects), </code></pre> <p>And your function looks like this:</p> <pre><code>@login_required def quote_projects(request): status = request.GET.get('status', None) status = dict(STATUS_CHOICES).get(status, None) if not status: raise Http404 return render_to_response( 'project/index.html', {'projects': Projects.objects.filter(status__value__exact = status)}, context_instance=RequestContext(request)) </code></pre> <p>And now your URL would be: <a href="http://example.com/project/?status=quoted" rel="nofollow">http://example.com/project/?status=quoted</a></p>
 

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