Skip to main content

Generate Django pages from Markdown, HTML, and Django template files.

Project description

Django Nanopages

Generate Django pages from Markdown, HTML, and Django template files.

Integrates well with:

  • nanodjango, to build a simple site with a single Python script
  • django-distill, to generate a static site
  • django-style, for clean base templates

Creating pages

Nanopages supports

  • page.md - markdown
  • page.html - Django template

Where two files have the same name, the markdown file will be used. These would both be served at /page/

HTML files are treated as Django templates, so you can also override blocks.

Files called index are special - they are the default content for their path, eg

  • section/index.md will be served at /section/
  • section/page.md will be served at /section/page/

Source pages can also provide context for your Django templates - see context documentation

Quickstart

Using with nanodjango

  1. Install nanodjango along with its optional dependencies, including django-nanopages and django-distill:

    pip install nanodjango[full]
    
  2. In your nanodjango script, register your directory of pages at a URL, at the end of your script:

    app.pages(url="", path="pages/")
    
  3. Put your markdown, HTML, or Django template files under the path - in this case, a dir next to your script called "pages".

  4. Optional: build to a static site with django-distill:

    nanodjango manage myscript.py distill-local static_site/
    

    (see django-distill docs for more configuration and deployment options)

Using with full Django

  1. Install:

    pip install django-nanopages
    
  2. Add it to your INSTALLED_APPS in settings.py:

    INSTALLED_APPS = [
        ...
        "django_nanopages",
    ]
    
  3. In your urls.py, register your directory of pages at a URL:

    from django_nanopages import Pages
    
    urlpatterns = [
        ...
        path("", Pages("pages/")),
    ]
    
  4. Put your markdown, HTML, or Django template files under the path - in this case, a dir called "pages".

  5. Optional: build to a static site with django-distill:

    ./manage.py distill-local static_site/
    

    (see django-distill docs for more configuration and deployment options)

Project details


Download files

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

Source Distribution

django_nanopages-0.1.0.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_nanopages-0.1.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file django_nanopages-0.1.0.tar.gz.

File metadata

  • Download URL: django_nanopages-0.1.0.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.2

File hashes

Hashes for django_nanopages-0.1.0.tar.gz
Algorithm Hash digest
SHA256 026d9ed9fac91c4a8f0b654c5ec11fa5c3dff320d9f93b32ec12bae35e619677
MD5 178d2951472fccac2fabded5c487cd05
BLAKE2b-256 18eb88ddab18bcc6b63f445e01072a4059815766ad33e66b5d873afa254d3d89

See more details on using hashes here.

File details

Details for the file django_nanopages-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_nanopages-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1ad78aa83a1a0ca7e69f61c08d17c8eadcdd227552a0eab9fb1dc171e8c3e983
MD5 9c8264a83ceee98256a96e46d11ded6b
BLAKE2b-256 2a006076e6c992581c17bc724f6fea3325f5d963cd94b3d734686a6fa3dccfe4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page