1

I'm using Django and Python 3.7. I have created a YAML file with seed data for my db ...

./myapp/fixtures/seed_data.yaml

How do I run this without generating a new migration for it, as is specified here -- Loading initial data with Django 1.7 and data migrations ? I think theoretically there may be times when I add data to the file and my need to re-run it so it would be a little cumbersome to generate a new migration every time.

Dave
  • 15,639
  • 133
  • 442
  • 830

1 Answers1

2

Migrations will only run once, as you already correctly noticed :)

However, you can always manually run a ./manage.py loaddata <fixture>. Don't know if that's what you're looking for.

  • Ah yes that "loaddata" was what I was missing! Thx – Dave Mar 20 '19 at 15:12
  • You're welcome. But you still might've a problem when you're loading the same data twice. Django doesn't have any "magic" to prevent this (of course). – Dominique Barton Mar 20 '19 at 15:21
  • Maybe its because I have "pk"s in my yaml file, but running this multiple times doens't seem to result in any errors so I think I might be good. – Dave Mar 20 '19 at 15:32