Django说,表格并不存在

时间:2016-08-08 11:45:37

标签: python mysql django python-2.7 uwsgi

我的最终目标是在新服务器上部署Django应用程序,而我所拥有的只是旧服务器磁盘的原始映像。我已经在新服务器上设置了所有内容:uwsgi,python,mysql,django等。但是让我们解决我的问题:当我运行时

uwsgi --http :8001 --module propotolki.wsgi

它运行没有错误但是当我尝试通过浏览器访问它时,我在日志中获得以下堆栈跟踪:

Internal Server Error: / 
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 90, in get_response
    response = middleware_method(request)
  File "./apps/middleware/middleware.py", line 11, in process_request
    if RedirectHandler.objects.filter(is_active=True, redirect_from=request.path).exists():
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 512, in exists
    return self.query.has_results(using=self.db)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py", line 409, in has_results
    return bool(compiler.execute_sql(SINGLE))
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 781, in execute_sql
    cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py", line 53, in execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 99, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py", line 53, in execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/mysql/base.py", line 124, in execute
    return self.cursor.execute(query, args)
  File "/usr/local/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 205, in execute
    self.errorhandler(self, exc, value)
  File "/usr/local/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
ProgrammingError: (1146, "Table 'propotolki.middleware_redirecthandler' doesn't exist")

这是我从mysql控制台获得的内容,证明表 存在:

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| propotolki         |
+--------------------+
4 rows in set (0.00 sec)

mysql> use propotolki;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
+---------------------------------------+
| Tables_in_propotolki                  |
+---------------------------------------+
| auth_group                            |
| auth_group_permissions                |
| auth_permission                       |
| auth_user                             |
| auth_user_groups                      |
| auth_user_user_permissions            |
| bla_files_blafile                     |
| bla_files_sitefiles                   |
| calc_anglealum                        |
| calc_anglesteelwhite                  |
| calc_baseheight                       |
| calc_cellsize                         |
| calc_color                            |
| calc_outgo_bc_25                      |
| calc_pendant                          |
| calc_price                            |
| calc_roofcolor                        |
| calc_size                             |
| catalog_brand                         |
| catalog_category                      |
| catalog_colortemperature              |
| catalog_diffuser                      |
| catalog_floortype                     |
| catalog_lightoutput                   |
| catalog_order                         |
| catalog_orderinfo                     |
| catalog_product                       |
| catalog_product_categories            |
| catalog_product_color_temperature     |
| catalog_product_diffuser              |
| catalog_product_floor_type            |
| catalog_product_light_output          |
| catalog_product_related               |
| catalog_product_related_categories    |
| catalog_productsliderimage            |
| catalog_sessionbasket                 |
| chunks_chunk                          |
| chunks_group                          |
| chunks_image                          |
| chunks_media                          |
| django_admin_log                      |
| django_content_type                   |
| django_ipgeobase_ipgeobase            |
| django_ipgeobase_ipgeobase_city       |
| django_ipgeobase_ipgeobase_country    |
| django_ipgeobase_ipgeobase_region     |
| django_session                        |
| django_site                           |
| feedback_feedback                     |
| gallery_gallerygroup                  |
| gallery_galleryimage                  |
| left_menu_leftmenuitem                |
| middleware_breadcrumbs                |
| middleware_flatpages                  |
| middleware_redirecthandler            |
| middleware_slidebar                   |
| propotolki.django_content_type        |
| propotolki.middleware_redirecthandler |
| south_migrationhistory                |
| thumbnail_kvstore                     |
| watson_searchentry                    |
+---------------------------------------+
61 rows in set (0.01 sec)

我远不是Django专家,所以请询问任何所需的信息。 我也尝试过做python manager.py syncdb,但我得到类似的错误,告诉其他表也不存在:

# python manage.py syncdb
Syncing...
Creating tables ...
Traceback (most recent call last):
  File "manage.py", line 9, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 415, in handle
    return self.handle_noargs(**options)
  File "/usr/local/lib/python2.7/dist-packages/south/management/commands/syncdb.py", line 92, in handle_noargs
    syncdb.Command().execute(**options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 415, in handle
    return self.handle_noargs(**options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/syncdb.py", line 112, in handle_noargs
    emit_post_sync_signal(created_models, verbosity, interactive, db)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/sql.py", line 216, in emit_post_sync_signal
    interactive=interactive, db=db)
  File "/usr/local/lib/python2.7/dist-packages/django/dispatch/dispatcher.py", line 185, in send
    response = receiver(signal=self, sender=sender, **named)
  File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/management/__init__.py", line 82, in create_permissions
    ctype = ContentType.objects.db_manager(db).get_for_model(klass)
  File "/usr/local/lib/python2.7/dist-packages/django/contrib/contenttypes/models.py", line 47, in get_for_model
    defaults = {'name': smart_text(opts.verbose_name_raw)},
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py", line 154, in get_or_create
    return self.get_queryset().get_or_create(**kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 373, in get_or_create
    return self.get(**lookup), False
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 301, in get
    num = len(clone)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 77, in __len__
    self._fetch_all()
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 854, in _fetch_all
    self._result_cache = list(self.iterator())
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 220, in iterator
    for row in compiler.results_iter():
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 710, in results_iter
    for rows in self.execute_sql(MULTI):
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 781, in execute_sql
    cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py", line 53, in execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 99, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py", line 53, in execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/mysql/base.py", line 124, in execute
    return self.cursor.execute(query, args)
  File "/usr/local/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 205, in execute
    self.errorhandler(self, exc, value)
  File "/usr/local/lib/python2.7/dist-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
    raise errorclass, errorvalue
django.db.utils.ProgrammingError: (1146, "Table 'propotolki.django_content_type' doesn't exist")

1 个答案:

答案 0 :(得分:1)

你的桌面名称是如何以“。”结尾的。在他们中?这是一个特殊的角色。

| propotolki.django_content_type        |
| propotolki.middleware_redirecthandler |

尝试:

ALTER TABLE `propotolki.middleware_redirecthandler` RENAME TO middleware_redirecthandler

您也需要对django_content_type表执行相同的操作。