23๐
โ
You need to define a variable on the url. For example:
url(r'^pay/summary/(?P<value>\d+)/$', views.pay_summary, name='pay_summary')),
In this case you would be able to call pay/summary/0
It could be a string true/false by replacing \d+
to \s+
, but you would need to interpret the string, which is not the best.
You can then use:
<a href="{% url 'pay_summary' value=0 %}">my link</a>
๐คDric512
26๐
To add to the accepted answer, in Django 2.0 the url syntax has changed:
path('<int:key_id>/', views.myview, name='myname')
Or with regular expressions:
re_path(r'^(?P<key_id>[0-9])/$', views.myview, name='myname')
๐คRexcirus
- Django โ Function inside a model. How to call it from a view?
- Why isn't my Django User Model's Password Hashed?
- Enable PK based filtering in Django Graphene Relay while retaining Global IDs
Source:stackexchange.com