Opened 10 years ago

Closed 10 years ago

#7146 closed (invalid)

Initial SQL data should accept plain python!!!

Reported by: Italo Maia Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Keywords: database, initial data
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


Well, one should be able to use plain python with models to insert initial database data.
Sql does not seem the best solution for such.

Why just plain sql if models could do the job easily?

Change History (1)

comment:1 Changed 10 years ago by Russell Keith-Magee

Resolution: invalid
Status: newclosed

Initial SQL is intended to allow table-modifying statements to be executed at time of table creation. You _can_ use it to insert data, but this isn't reccommended practice. Instead, you should be using the serialization framework and the initial_data fixture. Python isn't allowed here either, but for a good reason - the JSON/YAML/XML serializers are a much more elegant and compact format for specifying initial data.

If you _really_ want to specify initial data using Python, you can use a post_sync trigger. Look at the way that initial root user is created by the django.contrib.auth app for an example of how this is done.

Note: See TracTickets for help on using tickets.
Back to Top