回到顶部

Contents

django.template.exceptions.TemplateDoesNotExist: django_filters/rest_framework/crispy_form.html

错误日志(error log):

django.request: 2020-05-27 15:43:54,265 E:\py_virtualenv\joyoo\lib\site-packages\django\utils\log.py [line:228] ERROR Internal Server Error: /api/articles/
Traceback (most recent call last):
  File "E:\py_virtualenv\joyoo\lib\site-packages\django\core\handlers\exception.py", line 34, in inner
    response = get_response(request)
  File "E:\py_virtualenv\joyoo\lib\site-packages\django\core\handlers\base.py", line 115, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "E:\py_virtualenv\joyoo\lib\site-packages\django\core\handlers\base.py", line 113, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "E:\py_virtualenv\joyoo\lib\site-packages\django\views\decorators\csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "E:\py_virtualenv\joyoo\lib\site-packages\rest_framework\viewsets.py", line 114, in view
    return self.dispatch(request, *args, **kwargs)
  File "E:\py_virtualenv\joyoo\lib\site-packages\rest_framework\views.py", line 505, in dispatch
    response = self.handle_exception(exc)
  File "E:\py_virtualenv\joyoo\lib\site-packages\rest_framework\views.py", line 465, in handle_exception
    self.raise_uncaught_exception(exc)
  File "E:\py_virtualenv\joyoo\lib\site-packages\rest_framework\views.py", line 476, in raise_uncaught_exception
    raise exc
  File "E:\py_virtualenv\joyoo\lib\site-packages\rest_framework\views.py", line 502, in dispatch
    response = handler(request, *args, **kwargs)
  File "E:\py_virtualenv\joyoo\lib\site-packages\rest_framework_extensions\cache\decorators.py", line 59, in inner
    kwargs=kwargs,
  File "E:\py_virtualenv\joyoo\lib\site-packages\rest_framework_extensions\cache\decorators.py", line 85, in process_cache_response
    response.render()
  File "E:\py_virtualenv\joyoo\lib\site-packages\django\template\response.py", line 106, in render
    self.content = self.rendered_content
  File "E:\py_virtualenv\joyoo\lib\site-packages\rest_framework\response.py", line 70, in rendered_content
    ret = renderer.render(self.data, accepted_media_type, context)
  File "E:\py_virtualenv\joyoo\lib\site-packages\rest_framework\renderers.py", line 724, in render
    context = self.get_context(data, accepted_media_type, renderer_context)
  File "E:\py_virtualenv\joyoo\lib\site-packages\rest_framework\renderers.py", line 702, in get_context
    'filter_form': self.get_filter_form(data, view, request),
  File "E:\py_virtualenv\joyoo\lib\site-packages\rest_framework\renderers.py", line 634, in get_filter_form
    html = backend().to_html(request, queryset, view)
  File "E:\py_virtualenv\joyoo\lib\site-packages\django_filters\rest_framework\backends.py", line 63, in to_html
    template = loader.get_template(self.template)
  File "E:\py_virtualenv\joyoo\lib\site-packages\django\template\loader.py", line 19, in get_template
    raise TemplateDoesNotExist(template_name, chain=chain)
django.template.exceptions.TemplateDoesNotExist: django_filters/rest_framework/crispy_form.html

解决办法(solution):

安装应用 django_filters 到 settings.py  的 INSTALLED_APPS.

You may need to add 'django_filters' to INSTALLED_APPS of settings.py

^_^
请喝咖啡 ×

前一篇: How to access the HttpRequest object in Django forms( Django view 给 forms 传递数据)
下一篇: ImportError: cannot import name 'QUERY_TERMS'
captcha