问题
another noob Django question. The below both work for me, is there any difference or anything I should be aware of ? I'm using Django 1.2.5. Thanks.
o = Staff()
form = StaffForm(request.POST, instance=o)
if form.is_valid():
o.save(using='dbName')
o = Staff()
form = StaffForm(request.POST, instance=o)
if form.is_valid():
f = form.save(commit = False)
f.save(using='dbName')
回答1:
The first example does not work - it doesn't update the instance from the form. Use the second.
来源:https://stackoverflow.com/questions/6118884/django-model-form-save-multi-database-question