1. Monwara LLC
  2. Untitled project
  3. django-url-tools

Commits

Branko Vukelic  committed 52fa20e

Allow usage of UrlHelper instance in add_param tag

  • Participants
  • Parent commits f2f46c4
  • Branches master

Comments (0)

Files changed (2)

File tests/test_add_params.py

View file
  • Ignore whitespace
 from unittest import TestCase
 
 from url_tools.templatetags.urls import add_params
+from url_tools.helper import UrlHelper
 
 
 class AddParamsTestCase(TestCase):
             add_params('/foo/bar?baz=0#frag', foo=1, bar=2),
             '/foo/bar?bar=2&foo=1&baz=0#frag'
         )
+
+    def test_add_parasm_with_helper_instance(self):
+        self.assertEqual(
+            add_params(UrlHelper('/foo/bar?baz=0#frag'), foo=1, bar=2),
+            '/foo/bar?bar=2&foo=1&baz=0#frag'
+        )

File url_tools/templatetags/urls.py

View file
  • Ignore whitespace
 
 @register.simple_tag
 def add_params(url, **kwargs):
-    url = UrlHelper(url)
+    if type(url) in [str, unicode]:
+        url = UrlHelper(url)
     url.update_query_data(**kwargs)
     return url.get_full_path()