17👍
✅
This line:
url(r'(?P<countryorcategory>[0-9A-Za-z._%+-]+)', explore_view, name='explore')
…is defining an url that takes an argument countryorcategory
in the template. You need to put an argument on your url either of the following in your template:
{% url 'explore' argument %}
{% url 'explore' countryorcategory=argument %}
If you want to continue to use non-argument urls with the same name, you can define additional urls with the same name but with different patterns. For example:
urlpatterns = patterns('',
url(r'(?P<countryorcategory>[0-9A-Za-z._%+-]+)', explore_view, name='explore'),
url(r'', explore_view, name='explore'),
)
Then {% url 'explore' %}
should work both with and without an argument.
8👍
For me, I forgot the namespace of the Route. Instead of
{% url 'login' %}
I should have written
{% url 'accounts:login' %}
with this configuration:
# root URLs
url(r'^accounts/', include('myproject.accounts.accounts.urls', namespace='accounts'))
# accounts URLs
url(r'^login$', views.login, name='login')
- How do you raise a python exception and include additional data for Sentry?
- Additional Serializer Fields in Django REST Framework 3
- How should I validate HTML in Django templates during the development process?
1👍
I’m assuming you are using a template with something like this :
{% url 'explore' argument %}
And this error probably means that the argument
is not set to anything.
- FileField Size and Name in Template
- How would I override the perform_destroy method in django rest framework?
- Django.core.exceptions.FieldDoesNotExist: model has no field named <function SET_NULL at 0x7fc5ae8836e0>
- Django model: Email field unique if not null/blank
Source:stackexchange.com