django-subdomains icon indicating copy to clipboard operation
django-subdomains copied to clipboard

Retrieve URL without displaying it

Open nmundar opened this issue 11 years ago • 1 comments

django supports this syntax for url tag:

{% url 'path.to.view' arg arg2 as the_url %}
<a href="{{ the_url }}">I'm linking to {{ the_url }}</a>

https://docs.djangoproject.com/en/dev/ref/templates/builtins/#url

But if i try to use your template tag i get django.template.base.TemplateSyntaxError:

TemplateSyntaxError: 'url' received some positional argument(s) after some keyword argument(s)

This syntax is really helpful if i have to include another template snippet that's usefull on multiple pages and just pass it some predetermined values for current template context, and it's really clean way to do it.

Example:

{% url 'make_donation' fundraiser_id=fundraiser.id as donation_url %}
{% include 'fundraisers/snippets/donate_box.html' with active=fundraiser.active closed_msg=closed_msg donation_url=donation_url %}

parse_bits locals:

{'takes_context': True, 'parser': <django.template.debug.DebugParser object at 0x7f1d87cba050>, 'name': 'url', 'bits': [u"'make_donation'", u'fundraiser_id=fundraiser.id', u'as', u'donation_url'], 'args': [<django.template.base.FilterExpression object at 0x7f1d87cd0610>], 'param': u'fundraiser_id', 'varargs': 'args', 'kwarg': {}, 'params': ['view', 'subdomain'], 'value': <django.template.base.FilterExpression object at 0x7f1d87cd04d0>, 'unhandled_params': ['subdomain'], 'kwargs': {'fundraiser_id': <django.template.base.FilterExpression object at 0x7f1d87cd04d0>}, 'bit': u'as', 'varkw': 'kwargs', 'defaults': (<object object at 0x7f1d8c075290>)  }

nmundar avatar Dec 10 '13 09:12 nmundar

Did anything happen with this? I'm having the same problem =(

lfalvarez avatar Apr 29 '15 22:04 lfalvarez