Code

Opened 6 years ago

Closed 6 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:

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?

Attachments (0)

Change History (1)

comment:1 Changed 6 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.