title: Cannot run Django unit test. Returns django.core.exceptions.ImproperlyConfigured
body: <p>I've been running unit tests (test.py) on my Django app for ages with no trouble. In my last session I was tinkering with my MYSQL database and models. I have been dropping and recreating the DB, deleting the migrations file and making migrations from scratch while I experiment with the models. </p>
  
  <p>Now, the unittests won't run. </p>
  
  <pre><code>Traceback (most recent call last):
    File "/opt/pycharm-2017.2.1/helpers/pycharm/_jb_unittest_runner.py", line 35, in &lt;module&gt;
      main(argv=args, module=None, testRunner=unittestpy.TeamcityTestRunner, buffer=not JB_DISABLE_BUFFERING)
    File "/usr/lib/python3.5/unittest/main.py", line 93, in __init__
      self.parseArgs(argv)
    File "/usr/lib/python3.5/unittest/main.py", line 140, in parseArgs
      self.createTests()
    File "/usr/lib/python3.5/unittest/main.py", line 147, in createTests
      self.module)
    File "/usr/lib/python3.5/unittest/loader.py", line 219, in loadTestsFromNames
      suites = [self.loadTestsFromName(name, module) for name in names]
    File "/usr/lib/python3.5/unittest/loader.py", line 219, in &lt;listcomp&gt;
      suites = [self.loadTestsFromName(name, module) for name in names]
    File "/usr/lib/python3.5/unittest/loader.py", line 153, in loadTestsFromName
      module = __import__(module_name)
    File "/home/danny/PycharmProjects/AskArby/deals/tests.py", line 3, in &lt;module&gt;
      from deals.models import Retailer
    File "/home/danny/PycharmProjects/AskArby/deals/models.py", line 5, in &lt;module&gt;
      class Retailer(models.Model):
    File "/home/danny/PycharmProjects/AskArby/deals/models.py", line 6, in Retailer
      name = models.CharField(max_length=200)
    File "/home/danny/.virtualenvs/AskArby/lib/python3.5/site-packages/django/db/models/fields/__init__.py", line 1061, in __init__
      super(CharField, self).__init__(*args, **kwargs)
    File "/home/danny/.virtualenvs/AskArby/lib/python3.5/site-packages/django/db/models/fields/__init__.py", line 172, in __init__
      self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE
    File "/home/danny/.virtualenvs/AskArby/lib/python3.5/site-packages/django/conf/__init__.py", line 56, in __getattr__
      self._setup(name)
    File "/home/danny/.virtualenvs/AskArby/lib/python3.5/site-packages/django/conf/__init__.py", line 39, in _setup
      % (desc, ENVIRONMENT_VARIABLE))
  django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
  </code></pre>
  
  <p>PyCharm also tells me no tests were found.</p>
  
  <p>This is the beginning of models.py:</p>
  
  <pre><code>from django.db import models
  from django.utils.translation import ugettext_lazy as _
  
  class Retailer(models.Model):
      name = models.CharField(max_length=200)
      base_url = models.URLField(max_length=500)
      currency = models.CharField(max_length=3)
      #css parameters for finding deals and subfields in HTML
      deal_container_css = models.CharField(max_length=300)
      title_css = models.CharField(max_length=300)
      price_css = models.CharField(max_length=300)
      old_price_css = models.CharField(max_length=300, null=True, blank=True)
      brand_css = models.CharField(max_length=300, null=True, blank=True)
      image_css = models.CharField(max_length=300, null=True, blank=True)
      description_css = models.CharField(max_length=300, null=True, blank=True)
      #for things that look like deal containers but aren't
      exclude_css = models.CharField(max_length=300, null=True, blank=True)
      shipping_css = models.CharField(max_length=300, null=True, blank=True)
      product_model_css = models.CharField(max_length=300, null=True, blank=True)
  </code></pre>
  
  <p>tests.py:</p>
  
  <pre><code>from django.test import TestCase
  import unittest
  from deals.models import Retailer
  
  class RetailerTests(TestCase):
      fixtures = ['initial_data.json']
  
  class TestRetailer(unittest.TestCase):
  
      def setUp(self):
          self.bestbuy = Retailer(Retailer.objects.get(pk=1))
  
      def test_name(self):
          self.assertEqual(self.bestbuy.name, 'Best Buy')
  </code></pre>
  
  <p>I'm using Pycharm, running runserver as a manage.py command. I have tried setting DJANGO_SETTINGS_MODULE from the command line, and it echos back the right answer: AskArby.settings. I try to call settings.configure() and it tells me settings are already configured.</p>
  
  <p>Also, when I run runserver I get this warning:</p>
  
  <pre><code>?: (1_8.W001) The standalone TEMPLATE_* settings were deprecated in Django 1.8 and the TEMPLATES dictionary takes precedence. You must put the values of the following settings into your default TEMPLATES dict: TEMPLATE_DIRS.
  deals.Marketplace.listing: (fields.W340) null has no effect on ManyToManyField.
  </code></pre>
  
  <p>Why is my app seemingly failing to run my unit tests in test.py?</p>