Renyi
Renyi

Reputation: 183

Django model form save (multi database) question

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')

Upvotes: 0

Views: 1367

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 599788

The first example does not work - it doesn't update the instance from the form. Use the second.

Upvotes: 1

Related Questions