Answer the question
In order to leave comments, you need to log in
How to correctly pass a parameter in Django to url?
I'm using the slug model to navigate to articles via titles in the address bar. I wrote everything in the URL as in the documentation:
urlpatterns = patterns('content.views',
url(r'^publication/add/', 'add_publication', name = 'Add_publication'),
url(r'^publication/(?P<slug>[a-z0-9_-]+)/$', 'get_publication', name = 'Get_publication'),
url(r'^publication/edit/(?P<slug>[a-z0-9_-]+)/$', 'edit_publication', name = 'Edit_publication'),
<a href="{% url 'Edit_publication' publication.slug %}" class="btn btn-warning">Редактировать новость</a>
<a href="/publication/edit/{{ publication.slug }}" class="btn btn-warning">Редактировать новость</a>
Answer the question
In order to leave comments, you need to log in
{% url 'Edit_publication' slug=publication.slug %}
What outputs? slug is empty?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question