1👍
The problem is probably in your urls.py.
The update_form
view takes an argument id
, so you should include it in the url pattern.
url(r'^update_form/(?P<id>\d+)/$', update_form, name='update_form')
For example, to edit the object with id=1, you would go to /update_form/1/
You would have to include the id in the template context
return render_to_response('update_form.html'{'form':form, 'id': id},
context_instance=RequestContext(request))
And include it it the form action:
<form action ="/update_form/{{ id }}/" method="post">{%csrf_token%}
Using the url tag would be slightly better:
<form action ="{% url 'update_form' %}" method="post">{%csrf_token%}
1👍
You should pass the id
of the row to the update_form
view:
<form action="{% url 'update_form' id %}" method="post">
And in urls.py:
url(r'^update_form/(?P<id>\d+)/$', update_form, name='update_form'),
- [Answered ]-Django: sorl-thumbnail image not updated right away because of cache
- [Answered ]-Define an order for ManyToManyField by through model field with Django
- [Answered ]-How to limit access to various services per user using Django-mama-CAS?
Source:stackexchange.com