簡體   English   中英

沒有這樣的列:django_content_type.name

[英]no such column: django_content_type.name

我在example.com的網站上部署了django-oscar的示例應用程序沙箱。 我想將其移至example.com:8000並在example.com網址上運行另一個項目。 我成功完成了第二部分,當你進入example.com時,你可以看到更新的django項目啟動並運行,但問題是,第一個django項目是django-oscar的沙箱,不會正確響應。

當您輸入example.com:8000時,您會看到當前的調試日志:

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']

現在我用Google搜索了這個錯誤,但我沒有得到任何有價值的結果。

還有,當我跑

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.

更新1:我也在使用django 1.7.8。

更新2:我將我的Django版本更改為1.8.1,makemigrations和migrate命令工作正常。 然后我再次運行服務器,現在我在日志中收到此錯誤:(我也刪除了apache設置,因為它們無關緊要!)

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

我終於可以解決我的問題。 問題是我使用django 1.8來運行manage.py migrate並且該項目是在django 1.7.1下開發的,因此遷移打破了問題。

所以我做的是我再次安裝了django 1.8.1,運行了manage.py migrate contenttypes 0001 ,然后卸載了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運行時,數據庫可以保留並移回項目,而不是刪除本地數據庫。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM