Django TemplateSyntaxError - 'static files'는 등록된 태그 라이브러리가 아닙니다.
Django 3.0으로 업그레이드한 후 다음과 같은 메시지가 나타납니다.TemplateSyntaxError
:
In template /Users/alasdair//myproject/myapp/templates/index.html, error at line 1
'staticfiles' is not a registered tag library. Must be one of: admin_list admin_modify admin_urls cache i18n l10n log static tz
여기 내 템플릿이 있습니다.
{% load staticfiles %}
<img src="{% static 'my_image.html' %}">
템플릿에 다음 태그가 있는 경우:
{% load staticfiles %}
{% load static from staticfiles %}
{% load admin_static %}
그런 다음 다음으로 대체합니다.
{% load static %}
당신은 이 변화를 만들어야 합니다 왜냐하면{% load staticfiles %}
그리고.{% load admin_static %}
Django 2.1에서는 더 이상 사용되지 않으며 Django 3.0에서는 제거되었습니다.
- 해라
{% load static %}
대신에{% load staticfiles %}
- 만약 CSS나 다른 파일의 효과가 당신의 템플릿에 반영되지 않는다면, 또한 당신의 마지막에 다음 행을 쓰시오.
settings.py
파일
STATIC_URL = '/static/'
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
VENV_PATH = os.path.dirname(BASE_DIR)
STATIC_ROOT = os.path.join(VENV_PATH, 'static_root')
이것은 저에게 장고 3.1.4를 사용하는 데 효과가 있었습니다.
{% load static %}
<link rel"stylesheet" href = "{% static 'style.css' %}">
그것은 나에게 효과가 있습니다.
이것은 나를 대신해서 작동했습니다.{% load static from staticfiles %}
와 함께{% load static %}
여기서:
가상 환경 "venv" /lip/sshd3로 이동합니다.X/site-packages/leaflet/templates/leaflet/admin/widget.html 및 디렉토리의 모든 .HTML 파일
제 문제는 여기 문서의 4단계에 있었습니다. https://docs.djangoproject.com/en/3.2/howto/static-files/
"4. 앱의 정적 폴더에 정적 파일을 저장합니다.예를 들어 my_app/static/my_app/example.jpg"
일단 제 디렉토리 구조를 모든 작업과 일치하도록 수정했습니다.
언급URL : https://stackoverflow.com/questions/55929472/django-templatesyntaxerror-staticfiles-is-not-a-registered-tag-library
'sourcetip' 카테고리의 다른 글
매개 변수는 정말로 SQL 주입을 방지하기에 충분합니까? (0) | 2023.06.07 |
---|---|
SQL JOIN 두 개의 JSON 열, 두 개의 관련 ID별 (0) | 2023.06.07 |
vba: 함수에서 사전 반환 (0) | 2023.06.07 |
사용자가 저장 버튼을 누르기 전에 상태를 업데이트해야 합니까? (0) | 2023.06.07 |
연도 및 월("yyyy-mm" 형식)을 날짜로 변환하시겠습니까? (0) | 2023.06.07 |