Skip to main content

A module for Django that allows to build pattern libraries for your projects.

Project description

Django pattern library

A module for Django that helps you to build pattern libraries and follow the Atomic design methodology.


At the moment, the main focus is to allow developers and designers use exactly the same Django templates in a design pattern library and in production code.

There are a lot of alternative solutions for building pattern libraries already. Have a look at Pattern Lab and Astrum, for example. But at Torchbox we mainly use Python and Django and we find it hard to maintain layout on big projects in several places: in a project's pattern library and in actual production code. This is our attempt to solve this issue and reduce the amount of copy-pasted code.


Documentation is located here.

How to install

  1. Add pattern_library into your INSTALLED_APPS:

        # ...
        # ...
  2. Add pattern_library.loader_tags into the TEMPLATES setting. For example:

            'BACKEND': 'django.template.backends.django.DjangoTemplates',
            'DIRS': [],
            'APP_DIRS': True,
            'OPTIONS': {
                'context_processors': [
                'builtins': ['pattern_library.loader_tags'],

    Note that this module only supports the Django template backend out of the box.

  3. Set the PATTERN_LIBRARY_TEMPLATE_DIR setting to point to a template directory with your patterns:

    PATTERN_LIBRARY_TEMPLATE_DIR = os.path.join(BASE_DIR, 'project_styleguide', 'templates')

    Note that PATTERN_LIBRARY_TEMPLATE_DIR must be available for template loaders.

  4. Include pattern_library.urls into your urlpatterns. Here's an example

    from django.apps import apps
    from django.conf.urls import url, include
    urlpatterns = [
        # ... Your URLs
    if apps.is_installed('pattern_library'):
        urlpatterns += [
            url(r'^pattern-library/', include('pattern_library.urls')),

Developer docs

Developer docs can be found here.


  • [ ] Add a note about production usage
  • [ ] Tests: Add tests. It's ok to not bother about tests during prototyping, but it will be extremely hard to maintain the project without tests.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-pattern-library, version 0.2.4
Filename, size File type Python version Upload date Hashes
Filename, size django_pattern_library-0.2.4-py3-none-any.whl (24.2 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size django-pattern-library-0.2.4.tar.gz (22.9 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page