Description
I can't seem to get this working in a Django app or a Wagtail app. I'm getting...
Internal Server Error: /pattern-library/ Traceback (most recent call last): File "/home/arashi/.cache/pypoetry/virtualenvs/portfolio-Iy91sLkC-py3.8/lib64/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner response = get_response(request) File "/home/arashi/.cache/pypoetry/virtualenvs/portfolio-Iy91sLkC-py3.8/lib64/python3.8/site-packages/django/core/handlers/base.py", line 115, in _get_response response = self.process_exception_by_middleware(e, request) File "/home/arashi/.cache/pypoetry/virtualenvs/portfolio-Iy91sLkC-py3.8/lib64/python3.8/site-packages/django/core/handlers/base.py", line 113, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/arashi/.cache/pypoetry/virtualenvs/portfolio-Iy91sLkC-py3.8/lib64/python3.8/site-packages/django/views/generic/base.py", line 71, in view return self.dispatch(request, *args, **kwargs) File "/home/arashi/.cache/pypoetry/virtualenvs/portfolio-Iy91sLkC-py3.8/lib64/python3.8/site-packages/django/views/generic/base.py", line 97, in dispatch return handler(request, *args, **kwargs) File "/home/arashi/.cache/pypoetry/virtualenvs/portfolio-Iy91sLkC-py3.8/lib64/python3.8/site-packages/pattern_library/views.py", line 43, in get pattern_template_name = self.get_first_template(templates) File "/home/arashi/.cache/pypoetry/virtualenvs/portfolio-Iy91sLkC-py3.8/lib64/python3.8/site-packages/pattern_library/views.py", line 31, in get_first_template raise PatternLibraryEmpty( pattern_library.exceptions.PatternLibraryEmpty: No templates found in the pattern library at '/home/arashi/snow/Websites/Django/portfolio/project_styleguide/templates'
The templates are working for the project as a whole, but I can't go to /pattern-library/ . I get the error
PatternLibraryEmpty at /pattern-library/
Activity
bcdickinson commentedon Sep 26, 2020
I appreciate this was a while ago, sorry for the slow response. This error means that there are no templates in the locations that that pattern library expects to find them.
Could you tell me:
mazenshanti commentedon Oct 13, 2020
Hi @bcdickinson,
I may have the same problem:
PatternLibraryEmpty at /pattern-library/
No templates found matching: '(('atoms', ['patterns/atoms']), ('molecules', ['patterns/molecules']), ('organisms', ['patterns/organisms']), ('templates', ['patterns/templates']), ('pages', ['patterns/pages']))'
requirements.txt:
Django==3.1
django-pattern-library==0.2.9
wagtail==2.10.2
base.py:
structure:
.
├── manage.py
├── test
│ ├── init.py
│ ├── settings
│ │ ├── init.py
│ │ ├── base.py
│ │ ├── dev.py
│ │ └── production.py
│ ├── static
│ │ ├── css
│ │ │ └── test.css
│ │ └── js
│ │ └── test.js
│ ├── templates
│ │ ├── 404.html
│ │ ├── 500.html
│ │ ├── base.html
│ │ └── patterns
│ │ ├── atoms
│ │ │ ├── tags_test_atom
│ │ │ │ ├── tags_test_atom.html
│ │ │ │ └── tags_test_atom.yaml
│ ├── urls.py
│ └── wsgi.py
├── requirements.txt
I'm looking forward to use your tool and the Atomic methodology, thanks.
allcaps commentedon Oct 13, 2020
Your
test
app is not inINSTALLED_APPS
.mazenshanti commentedon Oct 13, 2020
I tried to add another app and it works fine, @allcaps thanks.
allcaps commentedon Oct 14, 2020
Tests directory is project config code and not an 'app'. Equivalent to the output of 'django-admin startproject tests' However, any folder that contains an init can be a Django app. So adding this directory to installed apps let's Django discover the templates.
Project layouts are always a bit opinionated. :)
I'd like to keep templates in apps, instead of one global template folder. @bcdickinson Does that make sense with PL? App loader templates in multiple locations?
bcdickinson commentedon Oct 14, 2020
@allcaps the need to put patterns in a single directory is going to be removed in an upcoming release, this PR sheds a bit more light on it: #124
thibaudcolas commentedon May 20, 2021
I will close this now as I believe our most recent release will likely have helped with this. The pattern library now supports crawling all apps’ templates, and soon will also support
DIRS
templates (#145).feat: use pathlib.Path for template paths