0

Created a new model called Email, but using makemigrations and migrate I am getting no changes detected. Upon runserver, I get the following error:

ProgrammingError at /admin/uploader/email/
relation "uploader_email" does not exist
LINE 1: SELECT COUNT(*) AS "__count" FROM "uploader_email"

I have tried every suggestion on stackoverflow, I have:

  1. Deleted migrations files
  2. ran migrate --fake and --fake-initial
  3. migrate uploader (calling the app specifically)

Nothing is working, the DB simply will not be modified.

Any ideas?

Model:

class Email(models.Model):
    ROUNDS_LIST = (
        ('1', '1'), ('2', '2'), ('3', '3'), ('4', '4'), ('5', '5'), ('6', '6'), ('7', '7'), ('8', '8'), ('9', '9'), ('10', '10'),
    )
    project = models.ForeignKey(Project)
    client = models.ForeignKey(Client, null=True, blank=True)
    name = models.CharField(max_length=256, null=True, blank=True)
    filename = models.CharField(max_length=256, null=True, blank=True)
    width = models.CharField(max_length=3, null=True, blank=True)
    height = models.CharField(max_length=3, null=True, blank=True)
    review_round = models.CharField(max_length=3, choices=ROUNDS_LIST, default=1)
    zip_file_upload = models.FileField(blank=True, null=True, upload_to=get_upload_file_name)

    def save(self, *args, **kwargs):
        self.slug = slugify(self.name)
        filename, file_extension = os.path.splitext(self.zip_file_upload.name)
        self.name = filename
        self.filename = filename + ".html"

        super(Email, self).save(*args, **kwargs)

    class Meta:
        verbose_name_plural = "HTML Emails"

    def __unicode__(self):
        return self.name

Stack trace:

Environment:

Request Method: GET
Request URL: http://127.0.0.1:8000/admin/uploader/email/

Django Version: 1.9.1
Python Version: 2.7.11
Installed Applications:
['grappelli',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.admin',
 'uploader.apps.UploaderAppConfig',
 'accounts',
 'crispy_forms',
 'imagekit',
 'storages',
 'boto']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'whitenoise.middleware.WhiteNoiseMiddleware']



Traceback:

File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  149.                     response = self.process_exception_by_middleware(e, request)

File "/usr/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  147.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/usr/local/lib/python2.7/site-packages/django/contrib/admin/options.py" in wrapper
  541.                 return self.admin_site.admin_view(view)(*args, **kwargs)

File "/usr/local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
  149.                     response = view_func(request, *args, **kwargs)

File "/usr/local/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  57.         response = view_func(request, *args, **kwargs)

File "/usr/local/lib/python2.7/site-packages/django/contrib/admin/sites.py" in inner
  244.             return view(request, *args, **kwargs)

File "/usr/local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapper
  67.             return bound_func(*args, **kwargs)

File "/usr/local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
  149.                     response = view_func(request, *args, **kwargs)

File "/usr/local/lib/python2.7/site-packages/django/utils/decorators.py" in bound_func
  63.                 return func.__get__(self, type(self))(*args2, **kwargs2)

File "/usr/local/lib/python2.7/site-packages/django/contrib/admin/options.py" in changelist_view
  1468.                 self.list_max_show_all, self.list_editable, self)

File "/usr/local/lib/python2.7/site-packages/django/contrib/admin/views/main.py" in __init__
  79.         self.get_results(request)

File "/usr/local/lib/python2.7/site-packages/django/contrib/admin/views/main.py" in get_results
  174.         result_count = paginator.count

File "/usr/local/lib/python2.7/site-packages/django/core/paginator.py" in _get_count
  72.                 self._count = self.object_list.count()

File "/usr/local/lib/python2.7/site-packages/django/db/models/query.py" in count
  371.         return self.query.get_count(using=self.db)

File "/usr/local/lib/python2.7/site-packages/django/db/models/sql/query.py" in get_count
  483.         number = obj.get_aggregation(using, ['__count'])['__count']

File "/usr/local/lib/python2.7/site-packages/django/db/models/sql/query.py" in get_aggregation
  464.         result = compiler.execute_sql(SINGLE)

File "/usr/local/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
  848.             cursor.execute(sql, params)

File "/usr/local/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
  79.             return super(CursorDebugWrapper, self).execute(sql, params)

File "/usr/local/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
  64.                 return self.cursor.execute(sql, params)

File "/usr/local/lib/python2.7/site-packages/django/db/utils.py" in __exit__
  95.                 six.reraise(dj_exc_type, dj_exc_value, traceback)

File "/usr/local/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
  64.                 return self.cursor.execute(sql, params)

Exception Type: ProgrammingError at /admin/uploader/email/
Exception Value: relation "uploader_email" does not exist
LINE 1: SELECT COUNT(*) AS "__count" FROM "uploader_email"
                                          ^
Scott Johnson
  • 107
  • 3
  • 8
  • Please post the *full* stack trace, and your model code. – solarissmoke Jul 17 '16 at 04:24
  • @solarissmoke Done! – Scott Johnson Jul 17 '16 at 04:38
  • Have you tried the steps in [this answer](http://stackoverflow.com/a/27008518/3955830)? Deleting the migrations will not clear Django's history of those migrations, and I suspect that is where your issue is. – solarissmoke Jul 17 '16 at 04:42
  • Yes, I ran: ./manage.py migrate --fake uploader zero with no success – Scott Johnson Jul 17 '16 at 04:52
  • Can you show the code i.e raising the exception for `uploader_email`._Besides this_ also check if you django_migrations table (in DB) has those migrations that you try to run with migrate. If so then delete _those_ and try again. – kapilsdv Jul 17 '16 at 06:07

0 Answers0