class VendorEditForm(forms.ModelForm):
class Meta:
model = Vendor
fields = ('avatar','description',)
context['form'] = self.form_class(self.request.GET, initial=??? )
# forms.py
# ...
class MyForm(forms.ModelForm):
class Meta:
model = MyModel
# views.py
# ...
def my_view(request, id):
instance = get_object_or_404(MyModel, id=id)
form = MyForm(request.POST or None, instance=instance)
if form.is_valid():
form.save()
return redirect('next_view')
return direct_to_template(request, 'my_template.html', {'form': form}