Database routers are for routing database queries. Forms and ModelForms are
for validating user input. If you want to route an update to a specific
database using a ModelForm, then you're going to have a bad time, ie.
you'll need to write a lot of code for the specific API that you want, as
opposed
Anthony Briggs writes:
> On 9 August 2016 at 14:29, Ben Finney wrote:
>
> > I'm wanting to specify *exactly one* database at *run-time*, and
> > have the operation use *that* database only (or fail if it can't).
> > The configured multi-database routing is no use for that.
>
> You seem to be ver
Thanks Ben
That confirms it for me. I'll go with migrations.
Mike
On 9/08/2016 2:50 PM, Ben Finney wrote:
Mike Dewhirst writes:
Can I ask why you are using manage.py to import csv data instead of a
migration?
There are different scenarios when each makes sense.
* When the data import is
On 9 August 2016 at 14:29, Ben Finney wrote:
> Anthony Briggs writes:
>
> > Or you can do it the Right Way(tm) and write a custom database router
>
> I appreciate the advice, but no, a database router is *not* right for
> this. Specifying the database routing policy in a configuration file is
>
Mike Dewhirst writes:
> Can I ask why you are using manage.py to import csv data instead of a
> migration?
There are different scenarios when each makes sense.
* When the data import is conceptually a defining feature of the
database (e.g. a collection of status values), and should exist from
Anthony Briggs writes:
> Right, so you can override the ModelForm's save() method, but you lose
> all of the other nice Django things, like model init, checking, etc.
> which you'll also have to recreate manually.
Yes, exactly. All I need is to tell the ModelForm which database it
should specify
Ben
Can I ask why you are using manage.py to import csv data instead of a
migration?
I ask because I'm just starting to think about an upcoming csv (xlsx
actually) import task of my own.
Thanks
Mike
On 9/08/2016 12:35 PM, Ben Finney wrote:
The ModelForm validation functionality is bein
Right, so you can override the ModelForm's save() method, but you lose all
of the other nice Django things, like model init, checking, etc. which
you'll also have to recreate manually.
Or you can do it the Right Way(tm) and write a custom database router as
per the reply before that. Look for `Pri
Anthony Briggs writes:
> I'm not sure what you're trying to do. Trying to write a management
> command using model forms makes no sense - wouldn't you just load the
> model instance directly in that case?
The ModelForm validation functionality is being used, to validate input.
Pseudocode::
Hi Ben,
I'm not sure what you're trying to do. Trying to write a management command
using model forms makes no sense - wouldn't you just load the model
instance directly in that case?
FWIW, there's only one instance of 'using' in Model forms, when saving over
an existing instance:
https://github.
Anthony Briggs writes:
> The database is normally routed via the model, rather than the form,
> so a ModelForm would generally just pick whatever the model uses.
Okay, so how do I specify the arguments the ModelForm will use when
interacting with the Model instance it creates?
I'm trying to hoo
Hi Ben,
The database is normally routed via the model, rather than the form, so a
ModelForm would generally just pick whatever the model uses. I would
imagine that trying to hack on the form directly would be a Bad Plan(tm).
https://docs.djangoproject.com/en/1.10/topics/db/multi-db/#automatic-dat
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 Mode
Note that on the friday of the conference, it looks like metro is
cancelling trains on several lines from 4:30 pm onwards. It
doesn't look like its cancelling everything, but you might have
to wait a while to get a ride home.
www.metrotrains.com.au/planned-works/
___
14 matches
Mail list logo