ProgrammingError relation" uploader_email"不存在

时间:2016-07-17 04:07:58

标签: django python-2.7

创建了一个名为Email的新模型,但是使用makemigrations和migrate我没有检测到任何更改。在runserver上,我收到以下错误:

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

我已尝试过stackoverflow的所有建议,我有:

  1. 已删除的迁移文件
  2. 运行migrate --fake和--fake-initial
  3. 迁移上传者(专门调用该应用)
  4. 没有任何工作,数据库根本不会被修改。

    有什么想法吗?

    型号:

    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
    

    堆栈追踪:

    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"
                                              ^
    

0 个答案:

没有答案