Closed mhalverson closed 6 years ago
Why don't you simply create new Event objects and call their .save() methods? It'd simply look like this:
for i in range(n):
event = Event()
event.date = datetime.date(2017, 1, 1) + datetime.timedelta(days=i)
event.name = 'auto_generated_event_{}'.format(i + 1)
event.review_state = random.choice(review_states)
event.save()
No need to create a temporary file, or call django's loaddata command. It also avoids any primary key conflicts that you currently have.
Sure, will do! There was no reason for choosing loaddata
vs event.save()
. I am new to django so I just picked the first implementation path that I found in the docs :)
kk, updated the pull request to use the event.save()
implementation.
Sample usage, from inside the VM:
This implementation is special-cased to just handle Events. If it becomes useful, we can generalize it to other palanaeum.models classes in subsequent commits.