I'm getting the following error message:
Reverse for 'code_front' with arguments '()' and keyword arguments '{'category_slug': u'code'}' not found.
I am new at this, please help.
I'm getting the following error message:
Reverse for 'code_front' with arguments '()' and keyword arguments '{'category_slug': u'code'}' not found.
I am new at this, please help.
Some basics:
get_absolute_url
/permalink
then make sure you've passed the right parameters.code_front
exists as a valid item for a reverse lookup.The error you're getting is because there's no match in your urls.py for the view and parameters you're using.
An example:
If your urls.py look like this:
urlpatterns = patterns('',
url(r'^YOUR_PATTERN/(?P<PARAMETER>.*)', your_view, name='code_front'),
)
You can reverse it's url like this:
In a template:
Using a value directly:
{% url code_front 'some_value' %}
You can use variables as parameter values:
{% url code_front variable %}
Using multiple parameters (if you're view needs them):
{% url code_front variable, another_variable %}
Or using named parameters:
{% url code_front parameter=variable %}
The same can be done in your python code:
reverse('code\_front', args=['some_value'])
reverse('code\_front', args=[variable])
reverse('code\_front', args=[variable, another_variable])
reverse('code\_front', kwargs={'parameter': variable})
You'll need to import the reverse
function:
from django.core.urlresolvers import reverse