Specify the database for a Django ModelForm instance

Phil Boutros philb at philb.ca
Tue Aug 9 13:56:34 EDT 2016


Ben Finney <ben+python at benfinney.id.au> wrote:
> Howdy all,
>
> How can I specify which database (by its alias name) a Django ModelForm
> should use
<snip>
> What is the equivalent for using='foo' when instantiating a ModelForm
> for the model, or calling its methods (ModelForm.clean, ModelForm.save,
> etc.)?

    You would specify it on the save method (using the same
"using='foo'") paremeter.  Do your work between calling save with
commit=false and doing the real save.

    For example:

http://stackoverflow.com/questions/37740848/use-a-specific-database-with-a-modelform

  
Phil
-- 
AH#61  Wolf#14  BS#89  bus#1  CCB#1  SENS  KOTC#4       philb at philb.ca
http://philb.ca         EKIII rides with me:  http://eddiekieger.com



More information about the Python-list mailing list