Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrieve URL without displaying it #25

Open
nmundar opened this issue Dec 10, 2013 · 1 comment
Open

Retrieve URL without displaying it #25

nmundar opened this issue Dec 10, 2013 · 1 comment

Comments

@nmundar
Copy link

nmundar commented Dec 10, 2013

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>)  }
@lfalvarez
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants