Je me suis cassé la tête à ce sujet pendant une journée entière mais je n'arrive pas à comprendre le problème. Cela s'est produit après avoir copié mon projet Django d'un PC à un autre.
Watching for file changes with StatReloader
Exception in thread Django-main-thread:
Traceback (most recent call last):
File "/Users/username/opt/anaconda3/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/Users/username/opt/anaconda3/lib/python3.7/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/Users/username/opt/anaconda3/lib/python3.7/site-packages/Django/utils/autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "/Users/username/opt/anaconda3/lib/python3.7/site-packages/Django/core/management/commands/runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "/Users/username/opt/anaconda3/lib/python3.7/site-packages/Django/utils/autoreload.py", line 76, in raise_last_exception
raise _exception[1]
File "/Users/username/opt/anaconda3/lib/python3.7/site-packages/Django/core/management/__init__.py", line 357, in execute
autoreload.check_errors(Django.setup)()
File "/Users/username/opt/anaconda3/lib/python3.7/site-packages/Django/utils/autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "/Users/username/opt/anaconda3/lib/python3.7/site-packages/Django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/username/opt/anaconda3/lib/python3.7/site-packages/Django/apps/registry.py", line 122, in populate
app_config.ready()
File "/Users/username/opt/anaconda3/lib/python3.7/site-packages/Django/contrib/admin/apps.py", line 24, in ready
self.module.autodiscover()
File "/Users/username/opt/anaconda3/lib/python3.7/site-packages/Django/contrib/admin/__init__.py", line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/Users/username/opt/anaconda3/lib/python3.7/site-packages/Django/utils/module_loading.py", line 47, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/Users/username/opt/anaconda3/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/Users/saitohiromasa/opt/anaconda3/lib/python3.7/site-packages/Django_summernote/admin.py", line 5, in <module>
from Django_summernote.widgets import SummernoteWidget, SummernoteInplaceWidget
File "/Users/username/opt/anaconda3/lib/python3.7/site-packages/Django_summernote/widgets.py", line 4, in <module>
from Django.contrib.staticfiles.templatetags.staticfiles import static
ModuleNotFoundError: No module named 'Django.contrib.staticfiles.templatetags'
Dans settings.py:
INSTALLED_APPS = [
'Django_summernote',
'accounts.apps.AccountsConfig',
'blogs.apps.BlogsConfig',
'Django.contrib.admin',
'Django.contrib.auth',
'Django.contrib.contenttypes',
'Django.contrib.sessions',
'Django.contrib.messages',
'Django.contrib.staticfiles',
]
Ma Django version est 3.0 Qu'est-ce qui ne va pas ici? S'il vous plaît, aidez-moi. Merci beaucoup!
Cela va être assez courant pendant un certain temps car tout le monde commence à se déplacer vers Django 3 au cours des prochaines années.
En plus de la réponse acceptée, c'est ce que j'ai ajouté pour prendre en charge à la fois Django 2 et Django 3 static
importations (esp . utile pour la gestion des packages)
try:
# Django 2
from Django.contrib.staticfiles.templatetags.staticfiles import static
except ModuleNotFoundError:
# Django 3
from Django.templatetags.static import static