Use Django Migration to create initial data


In order to initialize a new project I need to create a hundred instances of a Django model (for example a hundred authors). I hesitate to use a data migration to apply this initial data creation on our different platforms.

However, I don’t know if it’s a good practice to create these instances with migrations because I’ll have to keep them “forever” in my application’s migrations folder.

Perhaps it would be better to create a Django command to apply “by hand” and then remove it from the git repo later?

Thanks for your advice and have a nice day.


You probably want to use a fixture for that. No need for creating a command.

See Fixtures | Django documentation | Django

1 Like