#1978: Create Initial data via database API instead of SQL
-----------------------------+----------------------------------------------
 Reporter:  anonymous        |       Owner:  adrian
     Type:  enhancement      |      Status:  new   
 Priority:  normal           |   Milestone:        
Component:  django-admin.py  |     Version:        
 Severity:  normal           |    Keywords:        
-----------------------------+----------------------------------------------
 The ability to insert initial data via SQL is documented at
 [http://www.djangoproject.com/documentation/model_api/#providing-initial-
 sql-data]. However, Django already provides the OR mapper and database
 API, and it would be nice to create initial data using those tools. The
 initial SQL data documentation discusses putting ".sql" files in
 <appname>/sql/<modelname>.sql. I would like to add the ability to execute
 special files in a similar location (i.e.,
 <appname>/SOMEPLACE/<modelname>.py, where SOMEPLACE is "data" or "load" or
 something like that), so that database API calls like the following could
 be used (given the appropriate import statements for each):
 
 in mymodel.py:
 
 Mymodel(name="Fred").save()
 
 in mymodel2.py:
 
 # Mymodel2 has an "other" field, which is a Foreign Key field (to Mymodel)
 Mymodel2(name="baz", other=Mymodel.objects.get(name="Fred")).save()
 
 I think the syntax looks a little wordy (maybe an opportunity for a
 convenience method on the Model class?), but it allows my to create
 objects, including relationships among the model classes.
 
 In this scenario, there would need to be a way to ensure the order of
 execution, or we would need to be able to put creation statements for
 multiple models in a single script file.

-- 
Ticket URL: <http://code.djangoproject.com/ticket/1978>
Django <http://code.djangoproject.org/>
The web framework for perfectionists with deadlines.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates
-~----------~----~----~----~------~----~------~--~---

Reply via email to