i\'m new to django so i\'m sorry for my newbie question
i have a model and i need to let user edit data inside it using django forms or any other way.
Assuming you are using a ModelForm
, use the instance
keyword argument, and pass the model you are updating.
So, if you have MyModel
and MyModelForm
(the latter of which must extend django.forms.ModelForm
), then your code snippet might look like:
my_record = MyModel.objects.get(id=XXX)
form = MyModelForm(instance=my_record)
And then, when the user sends back data by POST:
form = MyModelForm(request.POST, instance=my_record)
Incidentally, the documentation for ModelForm
is here: http://docs.djangoproject.com/en/1.8/topics/forms/modelforms/