Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

192
Views
(django-template) link to current page but change values of variables

I have an archive.html template that is used by two views: myapp:paginated_view and myapp:whole_view.

Both views can be shown in a reversed or in a normal way. Now I want to create a link to change in between the ways.

That means there are four cases: (after the arrow what happens when you click that link)

  1. Whole_view & non-reversed -> whole_view and reversed
  2. Whole_view & reversed -> whole_view and non-reversed
  3. Paged_view & non-reversed -> paged_view (still on same page) and reversed
  4. Paged_view & reversed -> paged_view (still on same page) and non-reversed

I wonder if I had to declare all cases with if-clauses in the template or work with absolute url-pathes or create multiple templates, but these are my only ideas. Is there a better way? (I hope for something like: {% url current_page reverse=not reverse %}


My url conf: (in myapp)

urlpatterns = [
  url(r'^archive/(?P<reverse>[n]{0,1})/?$', views.ArchivePagedView.as_view(), name="paged_archive"),
  url(r'^archive/all/(?P<reverse>[n]{0,1})/?$', views.WholeArchiveView.as_view(), name='whole_archive'),
]

As you can see, in the url-conf reverse can be n or it's empty/doesn't exist. In my template it's true or false.

How to deal with this?

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!