Answer the question
In order to leave comments, you need to log in
How to correctly display the url in the template?
I get an error:
Reverse for 'goto' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
There is a function
def track_url(reguest):
page_id = None
url = '/rango/'
if reguest.method == 'GET':
if 'page_id' in reguest.GET:
page_id = reguest.GET['page_id']
try:
page = Page.objects.get(id=page_id)
page.views = page.views + 1
page.save()
url = page.url
except:
pass
return redirect(url)
url(r'^goto/', views.track_url, name='track_url'),
{% if category %}
{% if pages %}
<ul>
{% for page in pages %}
{% for tag in page.tags.all %}
<li><a href="{% url 'goto' %}?page_id={{page.id}}" target="_blank">{{ page.title }}</a></li>
Теги: <a href="{% url 'tags' tag.slug %}" target="_blank">{{ tag.title }}</a>
{%endfor %}
{% endfor %}
Answer the question
In order to leave comments, you need to log in
It is necessary to transfer the name or function to the url tag.
{% url 'track_url' %} or {% url 'app_name.views.track_url' %}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question