Reputation: 15831
I have a python file that creates objects with this method Category.objects.create. But I don't know how to run that fixture
Upvotes: 0
Views: 499
Reputation: 308899
Fixtures are serialized. Python code that populates the database is not a fixture.
If you want to populate the database with python code after the it has been created, I suggest you attach your creation function to the post_syncdb
signal. Note that the signal is sent per application.
In your callback function, you can check the created_signals
parameter, to see which models were created, and check whether you need to create the objects.
As a reference, have a look at the contrib apps that use the post_syncdb
signal, for example django.contrib.sites.manage
, which creates the default site instance only once.
Upvotes: 2