﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
1978	Create Initial data via database API instead of SQL	anonymous	Adrian Holovaty	"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."	enhancement	closed	Core (Management commands)		normal	wontfix			Unreviewed	0	0	0	0	0	0
