0

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.

0

2 Answers 2

2

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')
Sign up to request clarification or add additional context in comments.

1 Comment

Oh wow. Alright then I like this. I will try it as soon as I can and accept your answer.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.