Opened 17 years ago

Closed 17 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: dev
Severity: Keywords: database, initial 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

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 by Russell Keith-Magee, 17 years ago

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 management.py 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