Loading initial data with Django 1.7 and data migrations

前端 未结 7 1937
陌清茗
陌清茗 2020-11-27 09:39

I recently switched from Django 1.6 to 1.7, and I began using migrations (I never used South).

Before 1.7, I used to load initial data with a fixture/initial_d

7条回答
  •  醉梦人生
    2020-11-27 10:38

    In my opinion fixtures are a bit bad. If your database changes frequently, keeping them up-to-date will came a nightmare soon. Actually, it's not only my opinion, in the book "Two Scoops of Django" it's explained much better.

    Instead I'll write a Python file to provide initial setup. If you need something more I'll suggest you look at Factory boy.

    If you need to migrate some data you should use data migrations.

    There's also "Burn Your Fixtures, Use Model Factories" about using fixtures.

提交回复
热议问题