web-dev-qa-db-ja.com

djangoエラーは名前 'RemovedInDjango30Warning'をインポートできません

Guys im Djangoそして私は個人的なプロジェクトに取り組み始めたところ、悪用されるpycharmを決定しました(私はそれがエラーに関連しているかどうかと思います)。

python manage.py runserverを実行すると、以下のエラーメッセージが表示されます。私は少しグーグルしましたが、Djangoバージョンとの不整合が原因であるようです。

現在Django 3.0があり、グローバルとvenvの両方でチェックしました。

私はpyチャーム以外のプロジェクトを開始しようとしましたが、同じ問題が発生しています。 Djangoを再び使用するために必要なことをidkします。誰かがこれに遭遇しましたか?これはpycharmが原因ですか?もしそうなら、どうすれば問題を修正できますか?

(venv) aiden@aiden-XPS-15-9570:~/PycharmProjects/NewsAggregator$ python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

Exception in thread Django-main-thread:
Traceback (most recent call last):
  File "/home/aiden/.local/lib/python3.6/site-packages/Django/template/utils.py", line 66, in __getitem__
    return self._engines[alias]
KeyError: 'Django'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/aiden/.local/lib/python3.6/site-packages/Django/template/backends/Django.py", line 121, in get_package_libraries
    module = import_module(entry[1])
  File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/aiden/.local/lib/python3.6/site-packages/Django/contrib/admin/templatetags/admin_static.py", line 5, in <module>
    from Django.utils.deprecation import RemovedInDjango30Warning
ImportError: cannot import name 'RemovedInDjango30Warning'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/home/aiden/.local/lib/python3.6/site-packages/Django/utils/autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "/home/aiden/.local/lib/python3.6/site-packages/Django/core/management/commands/runserver.py", line 117, in inner_run
    self.check(display_num_errors=True)
  File "/home/aiden/.local/lib/python3.6/site-packages/Django/core/management/base.py", line 395, in check
    include_deployment_checks=include_deployment_checks,
  File "/home/aiden/.local/lib/python3.6/site-packages/Django/core/management/base.py", line 382, in _run_checks
    return checks.run_checks(**kwargs)
  File "/home/aiden/.local/lib/python3.6/site-packages/Django/core/checks/registry.py", line 72, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/home/aiden/.local/lib/python3.6/site-packages/Django/contrib/admin/checks.py", line 76, in check_dependencies
    for engine in engines.all():
  File "/home/aiden/.local/lib/python3.6/site-packages/Django/template/utils.py", line 90, in all
    return [self[alias] for alias in self]
  File "/home/aiden/.local/lib/python3.6/site-packages/Django/template/utils.py", line 90, in <listcomp>
    return [self[alias] for alias in self]
  File "/home/aiden/.local/lib/python3.6/site-packages/Django/template/utils.py", line 81, in __getitem__
    engine = engine_cls(params)
  File "/home/aiden/.local/lib/python3.6/site-packages/Django/template/backends/Django.py", line 25, in __init__
    options['libraries'] = self.get_templatetag_libraries(libraries)
  File "/home/aiden/.local/lib/python3.6/site-packages/Django/template/backends/Django.py", line 43, in get_templatetag_libraries
    libraries = get_installed_libraries()
  File "/home/aiden/.local/lib/python3.6/site-packages/Django/template/backends/Django.py", line 108, in get_installed_libraries
    for name in get_package_libraries(pkg):
  File "/home/aiden/.local/lib/python3.6/site-packages/Django/template/backends/Django.py", line 125, in get_package_libraries
    "trying to load '%s': %s" % (entry[1], e)
Django.template.library.InvalidTemplateLibrary: Invalid template library specified. ImportError raised when trying to load 'Django.contrib.admin.templatetags.admin_static': cannot import name 'RemovedInDjango30Warning'
5
Aiden Campbell

django.utils.deprecationインポートからRemovedInDjango30Warning

以下のファイルでこの行をコメント化

python3.6/site-packages/Django/contrib/admin/templatetags/admin_static.py .python3.6/sitepackages/Django/contrib/staticfiles/templatetags/staticfiles.py

1
y durga prasad

これは、Django=バージョンが原因です。アップグレードした可能性があります。

バージョン2に戻したくない場合は、仮想環境を作成し、pip install Django == 2.2を実行します。

1
Not Me