1
Try to override get_object() method of IdentityUpdate class to select specific object from request’s GET parameters.
class IdentityUpdate(UpdateView) :
model = Identity
form_class = IdentityForm
fields = '__all__'
template_name = 'resume.html'
def get_object(self):
query_update = request.GET.get('q4')
return get_object_or_404(Identity, pk=query_update)
If you prefer to work with function based view try to change Identity_Update() view to this:
def Identity_Update(request) :
# ID object given by user
query_update = request.GET.get('q4')
obj = get_object_or_404(Identity, pk=query_update)
if query_update :
updating_form = IdentityForm(request.POST, instance = obj)
....
0
I think the problem of you is :
when you post this form:
<form action="" method="post">{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Update" />
</form>
the value in your q4
input will not be submit cause they are in different form, so you can’d get the q4
(ID?) value in your view. So I suggest you should post then on the same form.
- Django 3rd party packages not working
- How to use a model in a Python Django project for multiple applications?
- Django query created object in tests not working
- Is it necessary to have all the types of requests in an app even though only post is being used for that app?
- What is the best way to use elasticsearch in Django Restframework
Source:stackexchange.com