Demo project for django-pattern-library issue #209
page_body.html
- A template that represents a page's body. In this demo it justinclude
s a call-to-action component.call_to_action.html
- A call-to-action component template that uses aninclude_block
from Wagtail to display a button.button.html
- A button component template used by the call-to-action component.
- Install
django-pattern-library==1.0.0
, Django 3.2 LTS, and Wagtail 4.1.1 with the includedrequirements.txt
pip install -r requirements-pattern-library-1.0.0.txt
- Run the development server
./manage.py runserver 0:8000
-
Navigate to the pattern library at http://localhost:8000/pattern-library/
-
Visit the
button.html
andcall_to_action.html
components, observe that the templates load properly -
Visit the
page_body.html
component.
The template is displayed, as in django-pattern-library==0.6.0
. (Click to enlarge)
A TypeError
is raised on django-pattern-library==0.7.0
and later. (Click to enlarge)
Stack trace
[12/Dec/2022 10:17:37] "GET /pattern-library/pattern/patterns/components/page_body.html HTTP/1.1" 200 5764
Internal Server Error: /pattern-library/render-pattern/patterns/components/page_body.html
Traceback (most recent call last):
File "/Users/joshua/dev/b-ggs/django-pattern-library-issue-209/venv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/Users/joshua/dev/b-ggs/django-pattern-library-issue-209/venv/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/joshua/dev/b-ggs/django-pattern-library-issue-209/venv/lib/python3.9/site-packages/django/views/generic/base.py", line 70, in view
return self.dispatch(request, *args, **kwargs)
File "/Users/joshua/dev/b-ggs/django-pattern-library-issue-209/venv/lib/python3.9/site-packages/django/views/generic/base.py", line 98, in dispatch
return handler(request, *args, **kwargs)
File "/Users/joshua/dev/b-ggs/django-pattern-library-issue-209/venv/lib/python3.9/site-packages/django/utils/decorators.py", line 43, in _wrapper
return bound_method(*args, **kwargs)
File "/Users/joshua/dev/b-ggs/django-pattern-library-issue-209/venv/lib/python3.9/site-packages/django/views/decorators/clickjacking.py", line 33, in wrapped_view
resp = view_func(*args, **kwargs)
File "/Users/joshua/dev/b-ggs/django-pattern-library-issue-209/venv/lib/python3.9/site-packages/pattern_library/views.py", line 95, in get
rendered_pattern = render_pattern(request, pattern_template_name)
File "/Users/joshua/dev/b-ggs/django-pattern-library-issue-209/venv/lib/python3.9/site-packages/pattern_library/utils.py", line 227, in render_pattern
return render_to_string(template_name, request=request, context=context)
File "/Users/joshua/dev/b-ggs/django-pattern-library-issue-209/venv/lib/python3.9/site-packages/django/template/loader.py", line 62, in render_to_string
return template.render(context, request)
File "/Users/joshua/dev/b-ggs/django-pattern-library-issue-209/venv/lib/python3.9/site-packages/django/template/backends/django.py", line 61, in render
return self.template.render(context)
File "/Users/joshua/dev/b-ggs/django-pattern-library-issue-209/venv/lib/python3.9/site-packages/django/template/base.py", line 170, in render
return self._render(context)
File "/Users/joshua/dev/b-ggs/django-pattern-library-issue-209/venv/lib/python3.9/site-packages/django/template/base.py", line 162, in _render
return self.nodelist.render(context)
File "/Users/joshua/dev/b-ggs/django-pattern-library-issue-209/venv/lib/python3.9/site-packages/django/template/base.py", line 938, in render
bit = node.render_annotated(context)
File "/Users/joshua/dev/b-ggs/django-pattern-library-issue-209/venv/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
return self.render(context)
File "/Users/joshua/dev/b-ggs/django-pattern-library-issue-209/venv/lib/python3.9/site-packages/pattern_library/loader_tags.py", line 82, in render
output = super().render(context)
File "/Users/joshua/dev/b-ggs/django-pattern-library-issue-209/venv/lib/python3.9/site-packages/django/template/loader_tags.py", line 195, in render
return template.render(context)
File "/Users/joshua/dev/b-ggs/django-pattern-library-issue-209/venv/lib/python3.9/site-packages/django/template/base.py", line 172, in render
return self._render(context)
File "/Users/joshua/dev/b-ggs/django-pattern-library-issue-209/venv/lib/python3.9/site-packages/django/template/base.py", line 162, in _render
return self.nodelist.render(context)
File "/Users/joshua/dev/b-ggs/django-pattern-library-issue-209/venv/lib/python3.9/site-packages/django/template/base.py", line 938, in render
bit = node.render_annotated(context)
File "/Users/joshua/dev/b-ggs/django-pattern-library-issue-209/venv/lib/python3.9/site-packages/django/template/base.py", line 905, in render_annotated
return self.render(context)
File "/Users/joshua/dev/b-ggs/django-pattern-library-issue-209/venv/lib/python3.9/site-packages/django/template/defaulttags.py", line 221, in render
return mark_safe(''.join(nodelist))
TypeError: sequence item 1: expected str instance, NoneType found