In the code below referring to django's urls.py file, I'm passing the pk as an argument in the url:
url(r'^data/edit_item/(?P<pk>\d )$', edit_data, name="edit_data")
I want to know if there is a way to pass two arguments in this kind of regular expression. I've tried several ways like:
url(r'^data/edit_item/(?P<pk>\d )$&header', edit_data, name="edit_data")
but I'm having a lot of trouble getting the right format.
The url is being called directly in the html:
{% if header|lower == "specie" %}
<a href="{% url 'edit_data' item.pk %}" role="button" aria-pressed="true" > Edit</a>
{% endif %}
So I need to pass the argument header in the html as well:
{% if header|lower == "specie" %}
<a href="{% url 'edit_data' item.pk header %}" role="button" aria-pressed="true" > Edit</a>
{% endif %}
CodePudding user response:
Can you try using from django.urls import path:
path('data/edit_item/<slug:pk>/<slug:header>/', edit_data, name="edit_data")
If you want to use url with regex, try this:
url(r'^data/edit_item/(?P<pk>\S )/(?P<header\S )/', edit_data, name="edit_data")
