I have a problem. When I create very simple test in Django I have exceptions like this:
import unittest
from django.test import Client
class ModelTest(unittest.TestCase):
def setUp(self):
self.client = Client()
def test_basic(self):
response = self.client.get('/login/')
self.assertEqual(response.status_code, 200)
The error I get is:
FAILED (errors=1)
Traceback (most recent call last):
File "C:\Python27\lib\unittest\case.py", line 329, in run
testMethod()
File "C:\inetpub\wwwroot\portal\ateris\portal\module\RiskCard\tests\test_models.py", line 11, in test_basic
response = self.client.get('/login/')
File "C:\Python27\lib\site-packages\django\test\client.py", line 500, in get
**extra)
File "C:\Python27\lib\site-packages\django\test\client.py", line 303, in get
return self.generic('GET', path, secure=secure, **r)
File "C:\Python27\lib\site-packages\django\test\client.py", line 358, in generic
data = force_bytes(data, settings.DEFAULT_CHARSET)
File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 48, in __getattr__
self._setup(name)
File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 42, in _setup
% (desc, ENVIRONMENT_VARIABLE))
ImproperlyConfigured: Requested setting DEFAULT_CHARSET, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
I don't know what I am doing wrong. I use the unittest documentation.
I am using PyCharm
Python ver: 2.7.12
Django ver: 1.8.5