[melbourne-pug] Specify the database for a Django ModelForm instance
Ben Finney
ben+python at benfinney.id.au
Mon Aug 8 20:38:19 EDT 2016
Howdy all,
How can I specify which database (by its alias name) a Django ModelForm
should use?
(I'm having trouble getting the message onto the Django forum, so I'm
asking this Python-related question here too.)
A Django ModelForm knows its corresponding model, and the fields
included.
The ModelForm instance clearly knows how to specify a database,
internally. It can validate its fields against the database, and can
save a new model instance to the database. This implies its operations
have knowledge of which database to use.
What I need is to access that as an external user, when creating the
instance. I can't find how to specify any database other than the
default, when creating the ModelForm nor when it interacts with the
database.
What is the equivalent for using='foo' when instantiating a ModelForm
for the model, or calling its methods (ModelForm.clean, ModelForm.save,
etc.)?
--
\ “A free press is one where it's okay to state the conclusion |
`\ you're led to by the evidence.” —Bill Moyers |
_o__) |
Ben Finney
More information about the melbourne-pug
mailing list