Opened 11 years ago
Closed 11 years ago
#22271 closed New feature (wontfix)
Providing initial SQL data
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.6 |
Severity: | Normal | Keywords: | intial sql data, |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
https://docs.djangoproject.com/en/1.6/howto/initial-data/#providing-initial-sql-data
why I cannot put all sql of different models in one file? Sometime it is better put them in one file which makes the viewing and comparing easier. Also it might be some work to put them into each separate file.
Note:
See TracTickets
for help on using tickets.
Well, strictly, I don't think there's anything that would stop you from putting all your initial SQL for an app into the file for a single model. The contents of initial SQL files aren't validated to make sure that they only apply to a single model, so the code will "just run".
The only difference would be *when* the code is run; the model file you choose to put the initial SQL in will determine the order in which it is executed. During initial development, the initial SQL file for a particular model won't be run unless that the table for that model has been created.
On top of all that, initial SQL is a pattern that is an "emergency escape hatch" - it's a way to handle the last 2% of use cases you can't hit with Django itself. I'm not sure it's worth spending a whole lot of time revamping initial SQL handling to support a slightly different organisation of initial SQL content.
If you've got a particularly compelling use case that I've missed, please start a discussion on django-developers.