Reputation: 384
I am trying to save the instance of the form to a different database.
Usually when executing a save on an object instance you will use object.save(using='db_alias')
, which I assumed would be for the form.save()
function.
Currently I am using...
form.save(using='db_alias')
This throws an error claiming save() got an unexpected keyword argument 'using'
.
Do I need to override the save()
function within this particular form to handle a db_alias
argument? I wasn't able to find anything regarding this error when searching, so I am asking here as last resort for the best foot forward. Thanks in advance.
Upvotes: 0
Views: 698
Reputation: 1
Edit: You have to run makemigrations --database= to populate tables into the said db I order for instance = form.save(commit=False); instance.save(using=) to work.
Upvotes: 0
Reputation:
you are right , you can't save form such way, but you can use commit=False
and then save the instance, for example:
instance = form.save(commit=False)
instance.save(using='db_alias')
Upvotes: 2