How to create a file from scratch in pycharm for Django
I can create a scratch file from the "Tools" → "New Scratch File ..." menu.
But Django options and environment variables are not automatically imported. Is there a way to do this now, or is this feature just for pure testing of python code.
I want to be able
from website.models import *
but i am getting this error
File "/Users/user1/.virtualenvs/test-env/lib/python2.7/site-packages/django/conf/__init__.py", line 40, in _setup
% (desc, ENVIRONMENT_VARIABLE))
thank
+3
source to share
1 answer
Thanks to @Leistungsabfall, here is a working solution :-)
import os, sys
sys.path.append(os.path.join('/Users/user1/gitroot/website1/web', 'myproject'))
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings")
from django.conf import settings
from website.models import *
+1
source to share