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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file cached_markdown_field-0.1-py2.py3-none-any.whl
.
File metadata
- Download URL: cached_markdown_field-0.1-py2.py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0409180e0de0892a321f1b2916d4907317dd5a0b637352e3db4c2571b685bce |
|
MD5 | 71ac1eb937ca0167380530c7540b5383 |
|
BLAKE2b-256 | 616cc9a46f5b474cceb61f567caed7fa18f2cce847c3db73fb25d58da5de68e9 |