title: django on production 500 server error for User related Model in Admin
body: <p>I have deployed my Django(1.10) site on google compute engine, everything was working fine, but suddenly one of my model throwing 500 Server Error in admin.
  I have googled around but couldn't find any solution.
  All other models are displaying properly in django admin except only one and that's TaggedArticles model.
  Idon't have changed anything in my site, what's can be wrong? as it happens suddenly  to my site.</p>
  
  <p>Here's my code:</p>
  
  <p><strong>settings.py:</strong></p>
  
  <pre><code>"""
  Django settings for brain project.
  
  Generated by 'django-admin startproject' using Django 1.10.5.
  
  For more information on this file, see
  https://docs.djangoproject.com/en/1.10/topics/settings/
  
  For the full list of settings and their values, see
  https://docs.djangoproject.com/en/1.10/ref/settings/
  """
  
  import os
  
  
  # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
  BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  
  
  # Quick-start development settings - unsuitable for production
  # For a test push to trigger build from codeship.
  # Second thing for CodeShip deployment push
  # See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
  
  # SECURITY WARNING: keep the secret key used in production secret!
  SECRET_KEY = '*******************'
  
  # SECURITY WARNING: don't run with debug turned on in production!
  DEBUG = False
  
  ALLOWED_HOSTS = ['127.0.0.1', '35.202.165.136', 'brainresearchtagging.com', 'www.brainresearchtagging.com', ]
  # INTERNAL_IPS = ['127.0.0.1']
  
  
  # Application definition
  
  INSTALLED_APPS = [
  'django.contrib.admin',
  'django.contrib.auth',
  'django.contrib.contenttypes',
  'django.contrib.sessions',
  'django.contrib.messages',
  'django.contrib.staticfiles',
  'debug_toolbar',
  'users',
  'article',
  'import_export',
  ]
  
  MIDDLEWARE = [
      'django.middleware.security.SecurityMiddleware',
      'whitenoise.middleware.WhiteNoiseMiddleware',
      'django.contrib.sessions.middleware.SessionMiddleware',
      'django.middleware.common.CommonMiddleware',
      'debug_toolbar.middleware.DebugToolbarMiddleware',
      'django.middleware.csrf.CsrfViewMiddleware',
      'django.contrib.auth.middleware.AuthenticationMiddleware',
      'django.contrib.messages.middleware.MessageMiddleware',
      'django.middleware.clickjacking.XFrameOptionsMiddleware',
  ]
  
  
  ROOT_URLCONF = 'brain.urls'
  
  TEMPLATES = [
      {
          'BACKEND': 'django.template.backends.django.DjangoTemplates',
          'DIRS': [os.path.join(BASE_DIR, 'templates')]
          ,
          'APP_DIRS': True,
          'OPTIONS': {
              'context_processors': [
                  'django.template.context_processors.debug',
                  'django.template.context_processors.request',
                  'django.contrib.auth.context_processors.auth',
                  'django.contrib.messages.context_processors.messages',
              ],
          },
      },
  ]
  
  WSGI_APPLICATION = 'brain.wsgi.application'
  
  # DATABASES = {
  DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.mysql',
          'NAME': 'DB_NAME',
          'USER': 'DB_USERNAME',
          'PASSWORD': 'DB_PASS',
          'HOST': 'localhost',
          'PORT': '',
          }
  }
  
  
  #Static Storage
  STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
  
  # Password validation
  # https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-    validators
  
  AUTH_PASSWORD_VALIDATORS = [
      {
          'NAME':    'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
      },
      {
          'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
      },
      {
          'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
      },
      {
          'NAME':    'django.contrib.auth.password_validation.NumericPasswordValidator',
      },
  ]
  
  
  # Internationalization
  # https://docs.djangoproject.com/en/1.10/topics/i18n/
  
  LANGUAGE_CODE = 'en-us'
  
  TIME_ZONE = 'UTC'
  
  USE_I18N = True
  
  USE_L10N = True
  
  USE_TZ = True
  
  
  # Static files (CSS, JavaScript, Images)
  # https://docs.djangoproject.com/en/1.10/howto/static-files/
  
  STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
  STATIC_URL = '/assets/'
  STATICFILES_DIRS = [os.path.join(BASE_DIR, 'assets'), ]
  
  
  # Authentication
  LOGIN_URL = 'users:login'
  LOGIN_REDIRECT_URL = 'users:dashboard'
  
  EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend'
  EMAIL_FILE_PATH = os.path.join(BASE_DIR, 'emails')
  
  # Django Import-Export
  IMPORT_EXPORT_USE_TRANSACTIONS = True
  </code></pre>
  
  <p>Here's Tagged Article's model:</p>
  
  <pre><code>choices = (
  ('yes', 'Yes'),
  ('no', 'No'),
  ('not sure', 'Not Sure'),
  </code></pre>
  
  <p>)</p>
  
  <pre><code>class TaggedArticle(models.Model):
      user = models.ForeignKey(User, related_name='tagging')
      email = models.EmailField(max_length=255)
      category_fit = models.CharField(choices=choices, max_length=255)
      article = models.ForeignKey(Article, related_name='articles')
      link = models.URLField(max_length=255,)
      relevant_feedback = models.TextField(blank=True)
      category = models.CharField(max_length=255,)
      created_at = models.DateTimeField(default=timezone.now, editable=False)
  </code></pre>
  
  <p><strong>Here's admin.py:</strong></p>
  
  <pre><code>class TaggedArticleAdmin(admin.ModelAdmin):
  date_hierarchy = 'created_at'
  fields = ['category_fit', 'article', 'link', 'relevant_feedback', 'category', 'user', 'email']
  list_display = ['article', 'link', 'user', 'email', 'relevant_feedback']
  list_filter = ['user', 'email']
  model = TaggedArticle
  
  
  admin.site.register(Tagged, TaggedArticleAdmin)
  </code></pre>
  
  <p><strong>Update:</strong>
  When i set debug=True, then it returns the following error:</p>
  
  <blockquote>
    <p>ValueError at /admin/users/taggedarticle/
    Database returned an invalid datetime value. Are time zone definitions for your database and pytz installed?
    Request Method: GET
    Request URL:    <a href="http://www.brainresearchtagging.com/admin/users/taggedarticle/" rel="nofollow noreferrer">http://www.brainresearchtagging.com/admin/users/taggedarticle/</a>
    Django Version: 1.10.5
    Exception Type: ValueError
    Exception Value:<br>
    Database returned an invalid datetime value. Are time zone definitions for your database and pytz installed?
    Exception Location: /root/virEnv/lib/python3.6/site-packages/django/db/models/functions/datetime.py in convert_value, line 181
    Python Executable:  /root/virEnv/bin/python3.6
    Python Version: 3.6.1
    Python Path:<br>
    ['/root/brain',
     '/root/brain/brain',
     '/root/virEnv/bin',
     '/root/virEnv/lib/python36.zip',
     '/root/virEnv/lib/python3.6',
     '/root/virEnv/lib/python3.6/lib-dynload',
     '/usr/local/lib/python3.6',
     '/root/virEnv/lib/python3.6/site-packages',
     '/root/virEnv/lib/python3.6/site-packages/odf',
     '/root/virEnv/lib/python3.6/site-packages/odf',
     '/root/virEnv/lib/python3.6/site-packages/odf',
     '/root/virEnv/lib/python3.6/site-packages/odf',
     '/root/virEnv/lib/python3.6/site-packages/odf',
     '/root/virEnv/lib/python3.6/site-packages/odf',
     '/root/virEnv/lib/python3.6/site-packages/odf']
    Server time:    Sat, 18 Nov 2017 11:55:01 +0000</p>
  </blockquote>