Skip to main content

Serve .md pages as Django views.

Project description

Django Markdown View

Serve .md pages as Django views.

This package aims to make it easy to serve .md files on Django sites.


  • This package needs tests, and to have Travis and Coveralls properly configured.


Tested with:

The Tested With section describes aspirational goals.

  • Python: 3.5, 3.6, 3.7, 3.8
  • Django: 2.2, 3.0


  • Django 2.2 requires SQLite 3.8.3
  • Django 2.2 supports Python 3.5, 3.6, and 3.7.
  • Django 3.0 supports Python 3.6, 3.7 and 3.8.

We highly recommend and only officially support the latest release of each series.


  1. Install with pip install django-markdown-view.

  2. Add 'markdown_view' to your INSTALLED_APPS settings.


    The dictionary of the application’s base. See Settings below

    For example, if settings are in config/settings/, then:

    BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))



Use one of MarkdownView, LoggedInMarkdownView, or StaffMarkdownView from markdown_view.views to serve a .md file

from markdown_view.views import StaffMarkdownView



All settings are optional. See markdown_view/ for the defaults.


    When present, the value is taken as a location to append to the list of dirs that Django’s django.template.utils.get_app_template_dirs will return when passed dirname=””. This is used to locate .md files in the root of the project, e.g., a file. Looks for BASE_DIR if MARKDOWN_VIEW_BASE_DIR is not found.


    A list of loaders that locate .md files. The default list includes only markdown_view.loaders.MarkdownLoader which will by default try to load .md files from root directories in INSTALLED_APPS packages much the same as Django’s django.template.loaders.app_directories.Loader looks to load from “templates”.


    The name of the directories in INSTALLED_APPS packages in which to locate .md files. Defaults to “” in order to locate .md filed in the root directories.


    The extensions to enable. These extensions are enabled be default:

    • toc:
      generates a Table of Contents. If toc is removed from extensions, then MARKDOWN_VIEW_TEMPLATE_USE_TOC must be set to False.
    • tables:
      enables tables.
    • fenced_code:
      enables code blocks. If fenced_code is removed from extensions, then MARKDOWN_VIEW_TEMPLATE_USE_HIGHLIGHT_JS, which provides the highlighting for code blocks, can be disabled.
    • markdown_view.markdown_extensions.ImageExtension:
      makes images responsive in bootstrap4.

    See and for more extensions.

    You can create your own extensions by following—Writing-Extensions-for-Python-Markdown


    The Django template that’ll be used to render the HTML that is generated from the Markdown. Set your own template to style your pages. Context includes:

    • markdown_content:
      The HTML produced from the Markdown.
    • use_highlight_js:
      If highlight.js is enabled.
    • use_toc:
      If the table of contents should be rendered.
    • markdown_toc:
      A table of contents from the headers of the Markdown. Not set when use_toc is False.
    • page_title:
      A guess at a page title, for now it’s the first row of the TOC. Not set when use_toc is False.

    Whether to render the TOC. If false, in the template context, use_toc is False and markdown_toc and page_title are not present.


    Whether to load and activate the highlight.js library in the template.

Experimental Settings


    If the request context should be used as a base when creating the context with which to render the Markdown internally. This is because the Markdown is rendered once first in order to prepend it with {% load static %}. This is not well tested; YMMV.


    Any extra context to send to the internal render of the Markdown. Can be used to expose context to template tags embedded in the Markdown. This is not well tested; YMMV.


At a high level, MarkdownView will:

  1. Use a template loader to locate .md given as file_name
  2. Render as a template, the contents of the .md file prepended with {{% load static %}}, into several context variables
  3. Serve the MARKDOWN_VIEW_TEMPLATE with the context variables


All contributions are very welcomed. Propositions, problems, bugs, and enhancement are tracked with GitHub issues and patches are submitted via pull requests.

We use Travis coupled with Coveralls as continious integration tools.


Wharton Computing

  • Ryan J. Sullivan


0.0.4 (2020-07-09)

  1. Some documentation that didn’t make it into 0.0.3

0.0.3 (2020-07-09)

  1. Correct a typo the README.rst
  2. Add ids to the sections in the template
  3. Make more settings configurable
  4. Provide settings to disable optional functionality
  5. Add settings to, and generally improve, the README.rst
  6. Changed the project description to say “views” instead of “templates”

0.0.2 (2020-07-06)

  1. Remove support for Django pre-2.2
  2. Adds missing file markdown_view/

0.0.1 (2020-06-16)

  1. Initial release.

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-markdown-view, version 0.0.4
Filename, size File type Python version Upload date Hashes
Filename, size django_markdown_view-0.0.4-py2.py3-none-any.whl (10.4 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size django-markdown-view-0.0.4.tar.gz (8.8 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page