Python 没有这样的列:django\u content\u type.name
我在example.com网站上部署了django oscar的示例应用程序沙盒。我想把它移动到example.com:8000,并在example.com的url上运行另一个项目。我成功地完成了第二部分,当您进入example.com时,您可以看到较新的django项目正在启动和运行,但问题是,第一个django项目是django oscar的沙箱,它无法正常响应 输入example.com:8000时,将看到当前调试日志:Python 没有这样的列:django\u content\u type.name,python,django,apache,django-oscar,Python,Django,Apache,Django Oscar,我在example.com网站上部署了django oscar的示例应用程序沙盒。我想把它移动到example.com:8000,并在example.com的url上运行另一个项目。我成功地完成了第二部分,当您进入example.com时,您可以看到较新的django项目正在启动和运行,但问题是,第一个django项目是django oscar的沙箱,它无法正常响应 输入example.com:8000时,将看到当前调试日志: no such column: django_content_typ
no such column: django_content_type.name
Request Method: GET
Request URL: http://example.com:8000/fa/
Django Version: 1.7.8
Exception Type: OperationalError
Exception Value:
no such column: django_content_type.name
Exception Location: /usr/local/lib/python2.7/dist-packages/django/db/backends/sqlite3/base.py in execute, line 485
Python Executable: /usr/bin/python
Python Version: 2.7.3
Python Path:
['/var/www/setak/setakenv/setakmain/django-oscar/sites/sandbox',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/PIL',
'/usr/lib/python2.7/dist-packages/gst-0.10',
'/usr/lib/python2.7/dist-packages/gtk-2.0',
'/usr/lib/python2.7/dist-packages/ubuntu-sso-client',
'/usr/lib/python2.7/dist-packages/ubuntuone-client',
'/usr/lib/python2.7/dist-packages/ubuntuone-control-panel',
'/usr/lib/python2.7/dist-packages/ubuntuone-couch',
'/usr/lib/python2.7/dist-packages/ubuntuone-installer',
'/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol']
现在我在谷歌上搜索了这个错误,没有得到任何有价值的结果
还有,当我跑步的时候
sudo python manage.py migrate
发生以下情况,我也没有找到任何正确的解决方案:
Operations to perform:
Synchronize unmigrated apps: reports_dashboard, treebeard, oscar, communications_dashboard, reviews_dashboard, debug_toolbar, widget_tweaks, offers_dashboard, catalogue_dashboard, sitemaps, compressor, django_extensions, dashboard, thumbnail, haystack, ranges_dashboard, checkout, gateway, django_tables2
Apply all migrations: customer, promotions, shipping, wishlists, offer, admin, sessions, contenttypes, auth, payment, reviews, analytics, catalogue, flatpages, sites, address, basket, partner, order, voucher
Synchronizing apps without migrations:
Creating tables...
Installing custom SQL...
Installing indexes...
Running migrations:
No migrations to apply.
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 377, 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 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py", line 165, in handle
emit_post_migrate_signal(created_models, self.verbosity, self.interactive, connection.alias)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/sql.py", line 268, in emit_post_migrate_signal
using=db)
File "/usr/local/lib/python2.7/dist-packages/django/dispatch/dispatcher.py", line 198, in send
response = receiver(signal=self, sender=sender, **named)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/management/__init__.py", line 83, in create_permissions
ctype = ContentType.objects.db_manager(using).get_for_model(klass)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/contenttypes/models.py", line 58, in get_for_model
" is migrated before trying to migrate apps individually."
RuntimeError: Error creating new content types. Please make sure contenttypes is migrated before trying to migrate apps individually.
我终于可以解决我的问题了。问题是,我使用django 1.8运行
manage.py migrate
,项目是在django 1.7.1下开发的,因此迁移导致了问题的解决
所以我所做的是,我再次安装了django 1.8.1,运行了manage.py迁移contenttype0001
,然后卸载了django 1.8.1,安装了django 1.7.8并运行了manage.py runserver
,一切都恢复正常,工作正常。我也遇到了同样的问题。
在我的例子中,我使用Django 1.10创建本地数据库,但我需要使用旧的Django版本(1.7)进行一些测试,因此我删除了本地数据库,并使用Django 1.7运行manage.py migrate
,然后错误就消失了
或者,当项目使用Django 1.10运行时,可以保留数据库而不是删除本地数据库,并在需要时将其移回项目中。是否尝试Django的建议并首先迁移contenttypes?@ger.s.brett是的。同样的错误也会发生!你是从django 1.8开始的,后来降级到django 1.7.8吗?@karthikr嗯,我想是的。故事是这样的,有一次我从1.7.x升级到1.8,当我看到它不工作时,我降级到1.7.8,最简单的事情就是重新创建数据库。也就是说,如果您没有太多数据,这个答案帮助我找到了一个解决方案,尽管我无法完全按照它来操作,因为我无法运行任何manage.py命令而不看到此错误(其他所有依赖的应用程序都尝试在初始化时访问contenttypes,即使没有定义数据库)。相反,我创建了一个单独的设置文件“initial.py”,它只在已安装的应用程序中定义了django应用程序。我可以先使用此设置模块运行迁移,然后切换到常规设置模块以完成所有特定于项目的迁移。对于与MySQL操作相关的错误,会引发此异常。例如:连接太多;无法解析主机名;握手不好;服务器正在关闭,通讯错误。
Traceback (most recent call last):
File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/handlers.py", line 63, in __call__
return self.application(environ, start_response)
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 170, in __call__
self.load_middleware()
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 50, in load_middleware
mw_class = import_string(middleware_path)
File "/usr/local/lib/python2.7/dist-packages/django/utils/module_loading.py", line 26, in import_string
module = import_module(module_path)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named transaction