2015-05-18 18 views
8

Tôi đã có hộp cát ứng dụng mẫu của django-oscar được triển khai trên trang web của tôi tại example.com. tôi muốn di chuyển điều đó đến example.com:8000 và chạy một dự án khác tại url example.com. Tôi đã làm thành công phần thứ hai, và khi bạn nhập example.com, bạn có thể xem dự án django mới hơn và chạy, nhưng vấn đề là, dự án django đầu tiên là sandbox của django-oscar, sẽ không phản hồi đúng cách.không có cột nào như vậy: django_content_type.name

khi bạn nhập example.com:8000, bạn sẽ thấy debug log hiện tại:

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

bây giờ tôi googled lỗi này và tôi đã không nhận được bất kỳ kết quả có giá trị.

Ngoài ra, khi tôi chạy

sudo python manage.py migrate 

sau đây sẽ xảy ra, mà tôi cũng không tìm thấy bất kỳ độ phân giải đúng để sửa chữa:

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. 

cập nhật 1: Tôi cũng đang sử dụng django 1.7.8 cho điều này.

cập nhật 2: Tôi đã thay đổi phiên bản Django thành 1.8.1, các lệnh hiển thị và di chuyển đã hoạt động. Sau đó, tôi chạy máy chủ một lần nữa, và bây giờ tôi nhận được lỗi này trong nhật ký của tôi: (Tôi cũng đã xóa các cài đặt apache vì chúng không liên quan!)

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 
+0

Bạn hãy thử những gì django được gợi ý và di chuyển contenttypes đầu tiên? –

+0

@ ger.s.brett vâng tôi đã làm. cùng một lỗi xảy ra! –

+0

Bạn đã bắt đầu với django 1.8, và sau đó hạ cấp xuống django 1.7.8? – karthikr

Trả lời

15

Tôi cuối cùng có thể giải quyết được vấn đề của mình. Vấn đề là tôi đã sử dụng django 1.8 để chạy manage.py migrate và dự án được phát triển theo django 1.7.1, vì vậy việc di chuyển đã phá vỡ mọi thứ. Vì vậy, những gì tôi đã làm là tôi đã cài đặt django 1.8.1 lần nữa, chạy manage.py migrate contenttypes 0001, sau đó gỡ cài đặt django 1.8.1, cài đặt django 1.7.8 và chạy manage.py runserver và mọi thứ trở lại bình thường và hoạt động tốt.

+1

Câu trả lời này đã giúp tôi giải quyết ngay cả khi tôi không thể theo dõi chính xác vì tôi không thể chạy bất kỳ lệnh manage.py nào mà không thấy lỗi này (một ứng dụng khác phụ thuộc vào cố gắng truy cập contenttypes khi khởi tạo, ngay cả khi không có cơ sở dữ liệu nào được xác định). Thay vào đó, tôi đã tạo tệp cài đặt riêng "initial.py" chỉ có ứng dụng django được xác định trong INSTALLED_APPS. Tôi đã có thể chạy di chuyển bằng cách sử dụng mô-đun cài đặt này đầu tiên, và sau đó chuyển sang mô-đun cài đặt thông thường của tôi để hoàn thành tất cả các dự án di chuyển cụ thể của dự án của tôi. – Brett

+0

Ngoại lệ này được nêu ra cho các lỗi liên quan đến hoạt động của MySQL. Ví dụ: quá nhiều kết nối; một tên máy chủ không thể được giải quyết; bắt tay xấu; máy chủ đang tắt, lỗi giao tiếp. –

0

Tôi gặp vấn đề tương tự. Trong trường hợp của tôi, tôi đã sử dụng Django 1.10 để tạo cơ sở dữ liệu cục bộ nhưng tôi cần sử dụng phiên bản Django cũ (1.7) để thực hiện một số thử nghiệm, vì vậy tôi đã xóa cơ sở dữ liệu cục bộ của mình và chạy manage.py migrate với Django 1.7.

Ngoài ra, thay vì xóa cơ sở dữ liệu địa phương, cơ sở dữ liệu có thể được lưu giữ và chuyển lại cho dự án một khi nó cần thiết khi chạy dự án với Django 1.10

Các vấn đề liên quan