Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: wwu-housing/django-roommate-search
base: 338c262d7b
...
head fork: wwu-housing/django-roommate-search
compare: 4491a73e08
Checking mergeability… Don't worry, you can still create the pull request.
  • 4 commits
  • 2 files changed
  • 0 commit comments
  • 1 contributor
View
9 roommate_search/templates/pagination.html → ..._search/templates/roommate_search/pagination.html
@@ -1,3 +1,4 @@
+{% load roommate_search %}
{% comment %}
You can use this template by including it within a div with our pagination class
like so:
@@ -11,9 +12,9 @@
{% if page_obj.has_previous %}
{% ifnotequal page_obj.previous_page_number page_obj.paginator.page_range|first %}
- <li><a href="?page={{ page_obj.paginator.page_range|first }}">&laquo; First</a></li>
+ <li><a href="?{% paginator_query_string page_obj request "first" %}">&laquo; First</a></li>
{% endifnotequal %}
- <li><a href="?page={{ page_obj.previous_page_number }}">&lsaquo; Previous</a></li>
+ <li><a href="?{% paginator_query_string page_obj request "previous" %}">&lsaquo; Previous</a></li>
{% endif %}
<li>
@@ -22,8 +23,8 @@
</li>
{% if page_obj.has_next %}
- <li><a href="?page={{ page_obj.next_page_number }}">Next &rsaquo;</a></li>
+ <li><a href="?{% paginator_query_string page_obj request "next" %}">Next &rsaquo;</a></li>
{% ifnotequal page_obj.next_page_number page_obj.paginator.page_range|last %}
- <li><a href="?page={{ page_obj.paginator.num_pages }}">Last &raquo;</a></li>
+ <li><a href="?{% paginator_query_string page_obj request "last" %}">Last &raquo;</a></li>
{% endifnotequal %}
{% endif %}
View
17 roommate_search/templatetags/roommate_search.py
@@ -25,3 +25,20 @@ def public_profile_url(user):
obj = Profile.objects.get(user=user)
return reverse("roommate_search_public_profile",
kwargs={"pk": obj.id})
+
+
+@register.simple_tag
+def paginator_query_string(page_obj, request, page_arg):
+ page_number = {
+ "first": page_obj.paginator.page_range[0],
+ "previous": page_obj.previous_page_number(),
+ "next": page_obj.next_page_number(),
+ "last": page_obj.paginator.num_pages,
+ }
+
+ query_string = request.GET.copy()
+
+ if page_number.has_key(page_arg):
+ query_string["page"] = page_number[page_arg]
+
+ return query_string.urlencode()

No commit comments for this range

Something went wrong with that request. Please try again.