Any idea how to load data that has models with ImageField
in django?
I cannot use fixtures for this as there’s no way to serialize images into the fixtures files.
I’m trying to use factory-boy
which works very well for tests but I cannot see how to run it as a standalone script because there’s no django management command for it.
Is python manage.py shell < myscript.py
a good approach to handle this or there’s a better way?
Note that I’m using a bucket for file storage with salted filenames, and I have signals that do stuff like indexing into Elasticsearch which I need to keep. and fixtures don’t do this.
Well, the question is actually about having django env for your script, I've misunderstood the question.
shell < script.py
, viable one-timermanage.py
integrations with IDE may be goodYour script may setup django env itself — same as manage.py shell
does, there's not much of black magic, something like
import os, django
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myapp.settings")
django.setup()