1👍
You don’t show exactly what you’re doing but it seems that you are running a standalone script. In order to do that you need to configure Django, as the error states – see the docs for an example of how to do that.
Note however that this sort of thing is usually better written as a custom manage.py script.
Source:stackexchange.com