Hello
I am trying to set up links to a view that allows to edit objects, in previous view. Model:
class List(models.Model):
user = models.ForeignKey(User)
name = models.CharField(max_length=200)
type = models.PositiveIntegerField(choices=TYPE_DICT)
def __unicode__(self):
return self.name
@models.permalink
def get_absolute_url(self):
return ('EditList', None, {'list_id':self.id} )
View:
lists = List.objects.filter(user=request.user)
array = []
for list in lists:
ListDict = {'Name':list.name, 'type':types[str(list.type)], 'edit':list }
array.append(ListDict)
context = { 'array':array,}
Template:
{% for dict in array %}
<tr>
{% for key,value in dict.items %}
{% ifequal key 'edit' %}
<td>{{ key }}</td><td><a href="{{ value.get_absolute_url }}">{{ value.name }}</a></td>
{% else %}
<td>{{ key }}: </td><td>{{ value }}</td>
{% endifequal %}
{% endfor %}
</tr>
{% endfor %}
and urls conf:
urlpatterns = patterns('tst.list.views',
(r'^$', 'list'),
(r'^edit/(?P<list_id>\d+)/$', 'EditList')
,
What this line with link gives me is http://localhost/list/ as url, not http://localhost/list/edit/%5Bobjectid%5D/
Can anyone please tell me what am i doing wrong?
Alan