forms.py:class FooForm(forms.ModelForm):
class Meta:
model = Foo
exclude = ['created']
views.py:class FooView(FormView):
success_url = '/some/url/'
template_name = 'some/template.html'
form_class = FooForm
model = Foo
def form_valid(self, form):
if 'foo' in self.request.session:
pk = self.request.session['foo']
foo = Foo.objects.get(pk=pk)
self.object = form.save(instance=foo)
else:
self.object = form.save()
self.request.session['foo'] = self.object.pk
return HttpResponseRedirect(self.get_success_url())
Выводит ошибку при попытке обновить модель через save(instance=foo):
TypeError at /some/url
save() got an unexpected keyword argument 'instance'
В чем проблема?
Django 1.9.0
Python 3.4.3