title: Python Django NameError: name 'datetime' is not defined
body: <p>After typing on my command line in the app's directory: </p>
  
  <pre><code>python manage.py runserver
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "manage.py", line 15, in &lt;module&gt;
      execute_from_command_line(sys.argv)
    File "C:\Users\Paulo\Coding\Python\lib\site-packages\django\core\management\__init__.py", line 371, in execute_from_command_line
      utility.execute()
    File "C:\Users\Paulo\Coding\Python\lib\site-packages\django\core\management\__init__.py", line 347, in execute
      django.setup()
    File "C:\Users\Paulo\Coding\Python\lib\site-packages\django\__init__.py", line 24, in setup
      apps.populate(settings.INSTALLED_APPS)
    File "C:\Users\Paulo\Coding\Python\lib\site-packages\django\apps\registry.py", line 112, in populate
      app_config.import_models()
    File "C:\Users\Paulo\Coding\Python\lib\site-packages\django\apps\config.py", line 198, in import_models
      self.models_module = import_module(models_module_name)
    File "C:\Users\Paulo\Coding\Python\lib\importlib\__init__.py", line 126, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File "&lt;frozen importlib._bootstrap&gt;", line 994, in _gcd_import
    File "&lt;frozen importlib._bootstrap&gt;", line 971, in _find_and_load
    File "&lt;frozen importlib._bootstrap&gt;", line 955, in _find_and_load_unlocked
    File "&lt;frozen importlib._bootstrap&gt;", line 665, in _load_unlocked
    File "&lt;frozen importlib._bootstrap_external&gt;", line 678, in exec_module
    File "&lt;frozen importlib._bootstrap&gt;", line 219, in _call_with_frames_removed
    File "C:\Users\Paulo\Coding\Django projects\Project 1\freezer\models.py", line 5, in &lt;module&gt;
      class Item(models.Model):
    File "C:\Users\Paulo\Coding\Django projects\Project 1\freezer\models.py", line 31, in Item
      added_date = models.DateField("date added", default=datetime.date.today)
  NameError: name 'datetime' is not defined
  </code></pre>
  
  <p>This similarly titled <a href="https://stackoverflow.com/questions/19934248/nameerror-name-datetime-is-not-defined">question</a> did not help me.  I have </p>
  
  <pre><code>from datetime import date
  </code></pre>
  
  <p>in my models.py.</p>
  
  <p>I am running python 3.6.5 and Django 2.0.4.  I put this app online a while ago, it is still working and models.py is identical.  I'm confused as to what I've done wrong.  Could it be linked to having to reset my windows 10 recently?  It removed a python install in the process (in my program files directory) and lots of other things.<br>
  It left one of my python installs alone.  From the command line I opened it up and imported datetime and used the function to return today's date.</p>
  
  <p>Here is my models.py:</p>
  
  <pre><code>from django.db import models
  from django.utils import timezone
  from datetime import date
  
  class Item(models.Model):
  
      FREEZER_DRAWERS = (
              (1, 'Kitchen: Top tray'),
              (2, 'Kitchen: Middle drawer'),
              (3, 'Kitchen: Bottom drawer'),
              )
  
      TYPES = (
              (1, 'Raw meat'),
              (2, 'Fruit and veg'),
              (3, 'Meal'),
              )
  
      author = models.ForeignKey('auth.User', on_delete=models.CASCADE)
      title = models.CharField("food", max_length=100)
      item_type = models.IntegerField(choices = TYPES, default = 1)
      added_date = models.DateField("date added", default=datetime.date.today)
      where = models.IntegerField(choices = FREEZER_DRAWERS, default = 1)
      expires_date = models.DateField(default = datetime.date.today)
      on_shopping_list = models.BooleanField()
  
      def __str__(self):
          return self.title
  </code></pre>
  
  <p>Thank you!  The is the first question in ages I haven't been able to answer by looking on these forums!</p>