Answer the question
In order to leave comments, you need to log in
A new entry is not added to the ModelForm to display on the page. Query is being updated. I tried everything, I don't know :( How to update ModelForm?
new_query = Queryes.objects.create(
name=form_q.cleaned_data['name'],
...
)
new_query.save()
ppk = new_query.pk
mdl = Queryes.objects.get(pk=ppk)
update_form = QueryesForm(request.POST, instance=mdl)
update_form.save()
context['html_data'] = render_to_string('filter_msgs.html', request=request,
context={'form_q': update_form})
Answer the question
In order to leave comments, you need to log in
1. Why save the newly created object (it is already saved)?
2. What for the same object anew to get from a DB?
3. Why change it with the same data it was created with?
4. It is not clear from the question whether you need to create a new object or edit an old one, in the code you are doing a strange, twice the same action, but in different ways.
Conclusion: complete misunderstanding of what you are doing.
Treatment: go through the django tutorial again or read the documentation thoughtfully.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question