43👍
✅
You can use a ModelForm to accomplish this. First define the ModelForm:
from django import forms
class QuestionForm(forms.ModelForm):
class Meta:
model = Question
Then, in your view:
question = Question.objects.get(pk=id)
if request.method == 'POST':
form = QuestionForm(request.POST, instance=question)
form.save()
👤ars
Source:stackexchange.com