Skip to main content

Cached Markdown field for Django and django-markdownx

Project description

CachedMarkdownField for Django Models

This Field caches compiled Markdown and then uses the cached value when queried. This saves time spent compiling Markdown on every request.

Example

 class NameAndDescription(models.Model):
     name = CharField(max_length=20)
     description = CachedMarkdownField()

 instance = NameAndDescription()
 instance.description = "text"
 assert instance.description == "<p>text</p>"

Settings

CachedMarkdownField recongnized two SETTINGS.py settings

# Enables caching
MARKDOWN_CACHE = True

# If false, will raise error if not already compiled
MARKDOWN_CACHE_RUNTIME = True

How does it work?

Internally CachedMarkdownField uses CompositeField and stores the cached value in separate field. CachedMarkdownField is a proxy and will add two fields into the actual model. In the example above instance.description returns a proxy object that maps the fields markdown and cached to the model fields description_markdown and description_cached.

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

cached_markdown_field-0.1-py2.py3-none-any.whl (4.2 kB view hashes)

Uploaded Python 2 Python 3

Supported by

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