I’m getting the following error when trying to render a template:
NoReverseMatch at /things/
Reverse for 'edit_things' with arguments '(u'<function generate at 0x10a970aa',)' and
keyword arguments '{}' not found.
In my template, the following works:
<a href="{% url add_thing %}" class="btn_plus">
But then I get an error here:
<td onclick="document.location = '{% url edit_thing thing.guid %}';" class="edit" id="edit_thing_{{ forloop.counter }}"> </td>
We’re not using:
{% load url from future %}. This is Django 1.4.
In my urls:
url(r'^edit_thing/(?P<thing_id>[\w_-]{1,32})/$', 'edit_thing', name='edit_thing'),
And the view looks like:
def edit_thing(request, thing_id):
Any ideas on what is going wrong? I can’t understand why add_things works fine in the template, and it crashes as soon as it gets to edit_thing. Could it be that edit_thing takes an argument? I’ve tried everything on Stackoverflow, and have tried every combination of things (including load url from future, and so forth).
Here’s my model:
class Thing(models.Model):
guid = models.CharField(max_length=Guid.LENGTH, blank=True, null=True, unique=True, default=Guid.generate)
class Meta:
app_label = 'things'
You need to change your model definition. Change the
default:You are getting a string representation of a function because you were passing the function itself:
In other words:
That should do it