我將數據庫從mysql更改爲postgre。由於數據庫中沒有數據,我只是刪除了每個應用程序的遷移文件夾。當我跑makemigrations事後,雖然,我得到這個錯誤:刪除Django遷移
/theme/admin.py", line 2, in <module>
from models import theme, theme_file
ImportError: No module named 'models'
之前的所有工作得很好,沒有什麼比被清潔的遷移文件夾以外的代碼改變。
任何想法?
/Users/jl/.virtualenvs/bolts3/bin/python /Users/jl/Desktop/Bolts/manage.py runserver 8000
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x108e15ae8>
Traceback (most recent call last):
File "/Users/jl/.virtualenvs/bolts3/lib/python3.5/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/Users/jl/.virtualenvs/bolts3/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 113, in inner_run
autoreload.raise_last_exception()
File "/Users/jl/.virtualenvs/bolts3/lib/python3.5/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception
six.reraise(*_exception)
File "/Users/jl/.virtualenvs/bolts3/lib/python3.5/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/Users/jl/.virtualenvs/bolts3/lib/python3.5/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/Users/jl/.virtualenvs/bolts3/lib/python3.5/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/jl/.virtualenvs/bolts3/lib/python3.5/site-packages/django/apps/registry.py", line 115, in populate
app_config.ready()
File "/Users/jl/.virtualenvs/bolts3/lib/python3.5/site-packages/django/contrib/admin/apps.py", line 23, in ready
self.module.autodiscover()
File "/Users/jl/.virtualenvs/bolts3/lib/python3.5/site-packages/django/contrib/admin/__init__.py", line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/Users/jl/.virtualenvs/bolts3/lib/python3.5/site-packages/django/utils/module_loading.py", line 50, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/Users/jl/.virtualenvs/bolts3/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 662, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/Users/jl/Desktop/Bolts/theme/admin.py", line 2, in <module>
from models import theme, theme_file
ImportError: No module named 'models'
我老實說不知道爲什麼錯誤會在沒有任何代碼被改變的情況下發生。但是,請嘗試在/theme/admin.py文件的第2行中將'from models import'更改爲'from .models import'。 –
這是我第一次嘗試。同樣的結果。 –
你能告訴我們你的項目目錄樹嗎? – Enix