Add markdown support for flat pages
This commit is contained in:
parent
884fd4579a
commit
01c9651131
4 changed files with 27 additions and 4 deletions
1
Pipfile
1
Pipfile
|
@ -9,6 +9,7 @@ name = "pypi"
|
||||||
|
|
||||||
django = "*"
|
django = "*"
|
||||||
python-decouple = "*"
|
python-decouple = "*"
|
||||||
|
markdown = "*"
|
||||||
|
|
||||||
|
|
||||||
[dev-packages]
|
[dev-packages]
|
||||||
|
|
13
Pipfile.lock
generated
13
Pipfile.lock
generated
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"_meta": {
|
"_meta": {
|
||||||
"hash": {
|
"hash": {
|
||||||
"sha256": "c9096173a460c37db5cae58c8f61c3371b5e1fe5d436ccc27c29091ebd06fc4f"
|
"sha256": "afe4d05c7a34f361ac700b159c1844aab93669730285b054bf92bbf33bd5ff60"
|
||||||
},
|
},
|
||||||
"host-environment-markers": {
|
"host-environment-markers": {
|
||||||
"implementation_name": "cpython",
|
"implementation_name": "cpython",
|
||||||
|
@ -9,9 +9,9 @@
|
||||||
"os_name": "posix",
|
"os_name": "posix",
|
||||||
"platform_machine": "x86_64",
|
"platform_machine": "x86_64",
|
||||||
"platform_python_implementation": "CPython",
|
"platform_python_implementation": "CPython",
|
||||||
"platform_release": "4.15.1-2-ARCH",
|
"platform_release": "4.15.4-1-ARCH",
|
||||||
"platform_system": "Linux",
|
"platform_system": "Linux",
|
||||||
"platform_version": "#1 SMP Sun Feb 4 22:27:45 UTC 2018",
|
"platform_version": "#1 SMP PREEMPT Sat Feb 17 16:01:38 UTC 2018",
|
||||||
"python_full_version": "3.6.4",
|
"python_full_version": "3.6.4",
|
||||||
"python_version": "3.6",
|
"python_version": "3.6",
|
||||||
"sys_platform": "linux"
|
"sys_platform": "linux"
|
||||||
|
@ -34,6 +34,13 @@
|
||||||
],
|
],
|
||||||
"version": "==2.0.2"
|
"version": "==2.0.2"
|
||||||
},
|
},
|
||||||
|
"markdown": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:9ba587db9daee7ec761cfc656272be6aabe2ed300fece21208e4aab2e457bc8f",
|
||||||
|
"sha256:a856869c7ff079ad84a3e19cd87a64998350c2b94e9e08e44270faef33400f81"
|
||||||
|
],
|
||||||
|
"version": "==2.6.11"
|
||||||
|
},
|
||||||
"python-decouple": {
|
"python-decouple": {
|
||||||
"hashes": [
|
"hashes": [
|
||||||
"sha256:1317df14b43efee4337a4aa02914bf004f010cd56d6c4bd894e6474ec8c4fe2d"
|
"sha256:1317df14b43efee4337a4aa02914bf004f010cd56d6c4bd894e6474ec8c4fe2d"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
import markdown
|
||||||
|
|
||||||
|
|
||||||
class Page(models.Model):
|
class Page(models.Model):
|
||||||
|
@ -18,5 +19,19 @@ class PageContent(models.Model):
|
||||||
title = models.CharField(max_length=200)
|
title = models.CharField(max_length=200)
|
||||||
content = models.TextField()
|
content = models.TextField()
|
||||||
|
|
||||||
|
def formated_content(self):
|
||||||
|
return markdown.markdown(
|
||||||
|
self.content,
|
||||||
|
extensions=[
|
||||||
|
'markdown.extensions.extra',
|
||||||
|
'markdown.extensions.admonition',
|
||||||
|
'markdown.extensions.nl2br',
|
||||||
|
'markdown.extensions.sane_lists',
|
||||||
|
'markdown.extensions.smarty',
|
||||||
|
'markdown.extensions.toc',
|
||||||
|
],
|
||||||
|
output_format='html5',
|
||||||
|
)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.title
|
return self.title
|
||||||
|
|
|
@ -3,5 +3,5 @@
|
||||||
{% block title %}{{ page.title }}{% endblock %}
|
{% block title %}{{ page.title }}{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{{ page.content|safe }}
|
{{ page.formated_content|safe }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in a new issue