как использовать django -эмотиконы в django 3 - PullRequest
0 голосов
/ 02 мая 2020

я нашел в пакете Django -PyPI django -emoticons, я установил его и сделал все в файле настроек, у меня даже есть {% load stati c%} в моем шаблоне, и я все еще есть ошибка вроде: «django .template.exceptions.TemplateSyntaxError:« staticfiles »не является зарегистрированной библиотекой тегов». в моем {% extends "blog / base. html"%} базовом шаблоне у меня также есть {% load stati c%}. Существуют ли другие учетные данные для Django 3, чтобы использовать этот пакет?

settings.py

INSTALLED_APPS = [
'blog.apps.BlogConfig',
'users.apps.UsersConfig',
'crispy_forms',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'emoticons',

]

шаблон

{% extends "blog/base.html" %}
{% load static %}
{% load crispy_forms_tags %}
{% load emoticons_tags %}
{% block content %}
   <div class="content-section">
       <form method="POST">
           {% csrf_token %}
           <fieldset class="form-group">
               <legend class="border-bottom mb-4">Blog Post</legend>
               {% emoticons %}
               {{ form|crispy }}
               {% endemoticons %}
           </fieldset>
           <div class="form-group">
               <button class="btn btn-outline-info" type="submit">Post</button>
           </div>
       </form>
   </div>
{% endblock content %}

Ответы [ 2 ]

0 голосов
/ 02 мая 2020

Похоже, что используемая вами версия смайлика несовместима с django 3. Вы можете просто изменить это, заглянув в каталог смайликов и заменить во всех html шаблонах строку:

{% load staticfiles %}<img class="emoticon emoticon-{{ code }}" src="{% static image %}" alt="{{ name }}" />

с

{% load static %}<img class="emoticon emoticon-{{ code }}" src="{% static image %}" alt="{{ name }}" />
0 голосов
/ 02 мая 2020
    Exception in thread django-main-thread:
Traceback (most recent call last):
  File "C:\Users\wtaur\AppData\Local\Programs\Python\Python38-32\lib\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 "C:\Users\wtaur\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\template\defaulttags.py", line 1021, in find_library
    return parser.libraries[name]
KeyError: 'staticfiles'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\wtaur\AppData\Local\Programs\Python\Python38-32\lib\threading.py", line 932, in _bootstrap_inner
    self.run()
  File "C:\Users\wtaur\AppData\Local\Programs\Python\Python38-32\lib\threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Users\wtaur\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\wtaur\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\commands\runserver.py", line 117, in inner_run
    self.check(display_num_errors=True)
  File "C:\Users\wtaur\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\base.py", line 392, in check
    all_issues = self._run_checks(
  File "C:\Users\wtaur\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\base.py", line 382, in _run_checks
    return checks.run_checks(**kwargs)
  File "C:\Users\wtaur\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\checks\registry.py", line 72, in run_checks
    new_errors = check(app_configs=app_configs)
  File "C:\Users\wtaur\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\contrib\admin\checks.py", line 76, in check_dependencies
    for engine in engines.all():
  File "C:\Users\wtaur\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\template\utils.py", line 90, in all
    return [self[alias] for alias in self]
  File "C:\Users\wtaur\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\template\utils.py", line 90, in <listcomp>
    return [self[alias] for alias in self]
  File "C:\Users\wtaur\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\template\utils.py", line 81, in __getitem__
    engine = engine_cls(params)
  File "C:\Users\wtaur\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\template\backends\django.py", line 25, in __init__
    options['libraries'] = self.get_templatetag_libraries(libraries)
  File "C:\Users\wtaur\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\template\backends\django.py", line 43, in get_templatetag_libraries
    libraries = get_installed_libraries()
  File "C:\Users\wtaur\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\template\backends\django.py", line 108, in get_installed_libraries
    for name in get_package_libraries(pkg):
  File "C:\Users\wtaur\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\template\backends\django.py", line 121, in get_package_libraries
    module = import_module(entry[1])
  File "C:\Users\wtaur\AppData\Local\Programs\Python\Python38-32\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\wtaur\AppData\Local\Programs\Python\Python38-32\lib\site-packages\emoticons\templatetags\emoticons_tags.py", line 8, in <module>
    from emoticons.settings import EMOTICONS_LIST
  File "C:\Users\wtaur\AppData\Local\Programs\Python\Python38-32\lib\site-packages\emoticons\settings.py", line 151, in <module>
    EMOTICON_TEMPLATE = get_template('emoticons/emoticon.html')
  File "C:\Users\wtaur\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\template\loader.py", line 15, in get_template
    return engine.get_template(template_name)
  File "C:\Users\wtaur\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\template\backends\django.py", line 34, in get_template
    return Template(self.engine.get_template(template_name), self)
  File "C:\Users\wtaur\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\template\engine.py", line 143, in get_template
    template, origin = self.find_template(template_name)
  File "C:\Users\wtaur\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\template\engine.py", line 125, in find_template
    template = loader.get_template(name, skip=skip)
  File "C:\Users\wtaur\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\template\loaders\base.py", line 29, in get_template
    return Template(
  File "C:\Users\wtaur\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\template\base.py", line 156, in __init__
    self.nodelist = self.compile_nodelist()
  File "C:\Users\wtaur\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\template\base.py", line 194, in compile_nodelist
    return parser.parse()
  File "C:\Users\wtaur\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\template\base.py", line 477, in parse
    raise self.error(token, e)
  File "C:\Users\wtaur\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\template\base.py", line 475, in parse
    compiled_result = compile_func(self, token)
  File "C:\Users\wtaur\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\template\defaulttags.py", line 1078, in load
    lib = find_library(parser, name)
  File "C:\Users\wtaur\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\template\defaulttags.py", line 1023, in find_library
    raise TemplateSyntaxError(
django.template.exceptions.TemplateSyntaxError: 'staticfiles' is not a registered tag library. Must be one of:
admin_list
admin_modify
admin_urls
cache
crispy_forms_field
crispy_forms_filters
crispy_forms_tags
crispy_forms_utils
i18n
l10n
log
static
tz
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...