I am trying to run a simple Django test in PyCharm, but its failing with the following stack trace-
/home/ramashishb/local/pyenv/testenv/bin/python /opt/pych
Go to menu file > settings > Django Support
and select correct settings file.
I was experiencing the same problem. I found that I was running the wrong type of test.
import unittest
class MySampleTest(unittest.TestCase):
Cause the error
django.core.exceptions.ImproperlyConfigured: Requested setting API_BASE_URL, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
Changing to the import to
from django.test import SimpleTestCase
Class MySampleTest(SimpleTestCase):
allowed my test to run from within pycharm
.