Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Django Summernote | 934 | 226 | 1 | 9 months ago | 73 | October 14, 2021 | 61 | mit | Python | |
Simply integrate Summernote editor with Django project. | ||||||||||
Django Markdown Editor | 726 | 20 | 3 | 16 days ago | 51 | March 31, 2022 | 34 | gpl-3.0 | JavaScript | |
Awesome Django Markdown Editor, supported for Bootstrap & Semantic-UI | ||||||||||
Django Wysiwyg | 468 | 149 | 5 | 7 years ago | 14 | August 17, 2016 | 17 | mit | HTML | |
A Django application for making Django textareas rich text editors. Certainly as a template tag and possibly as a form widget. | ||||||||||
Django Unfold | 368 | 3 days ago | 9 | mit | HTML | |||||
Modern Django admin theme for seamless interface development | ||||||||||
Django Widgy | 328 | 2 years ago | 66 | other | JavaScript | |||||
A CMS framework for Django built on a heterogenous tree editor. | ||||||||||
Django Froala Editor | 278 | 33 | 1 | 15 days ago | 88 | June 09, 2022 | 28 | CSS | ||
Package to integrate Froala WYSIWYG HTML rich text editor with Django. | ||||||||||
Django Front | 262 | 11 | 2 years ago | 50 | October 16, 2020 | 1 | mit | JavaScript | ||
Django-front is a front-end editing Django application | ||||||||||
Django_blog | 211 | 7 years ago | 15 | CSS | ||||||
a blog powered by django | ||||||||||
Django Prose | 137 | 16 days ago | 9 | January 27, 2023 | mit | Python | ||||
Wonderful rich-text editing for your Django project | ||||||||||
Django Tinymce4 Lite | 129 | 84 | 9 | 2 years ago | 24 | April 11, 2020 | 8 | mit | JavaScript | |
TinyMCE 4 editor widget for Django |
Django Prose provides your Django applications with wonderful rich-text editing capabilities.
To get started with Django Prose, all you need to do is follow just four steps.
Install django-prose
We use and suggest using Poetry, although Pipenv and plain pip will work seamlessly as well
poetry add django-prose
Add to INSTALLED_APPS
Add prose
in your Django project's installed apps (example: example/example/settings.py
):
INSTALLED_APPS = [
# Django stock apps (e.g. 'django.contrib.admin')
'prose',
# your application's apps
]
Run migrations
This is required so you can use Django Prose's built-in Document model:
python manage.py migrate prose
Include URLs
You need to edit the main urls.py
file of your Django project and include prose.urls
:
urlpatterns = [
path('admin/', admin.site.urls),
# other urls ...
path("prose/", include("prose.urls")),
]
Now, you are ready to go .
There are different ways to use Django prose according to your needs. We will examine all of them here.
Rich text content essentially is HTML. For this reason it needs to be manually marked as safe
, when rendered in Django templates. Example:
{{ document.content | safe}}
You might want to add rich-text content in a model that is just a few characters (e.g. 140), like an excerpt from an article. In that case we suggest using the RichTextField
. Example:
from django.db import models
from prose.fields import RichTextField
class Article(models.Model):
excerpt = RichTextField()
As mentioned above, you need to mark the article excerpt as safe
, in order to render it:
<div class="article-excerpt">{{ article.excerpt | safe}}</div>
In case you want to store large rich-text content, like the body of an article, which can span to quite a few thousand characters, we suggest you use the AbstractDocument
model. This will save large rich-text content in a separate database table, which is better for performance. Example:
from django.db import models
from prose.fields import RichTextField
from prose.models import AbstractDocument
class ArticleContent(AbstractDocument):
pass
class Article(models.Model):
excerpt = RichTextField()
body = models.OneToOneField(ArticleContent, on_delete=models.CASCADE)
Similarly here as well, you need to mark the article's body as safe
, in order to render it:
<div class="article-body">{{ article.body.content | safe}}</div>
You can create forms for your Django Prose models, to provide rich-text editing functionality. In that case, you will also need to render form.media
, to load Trix with its stylesheets.
<form method="POST" >
{% csrf_token %}
{{ form.as_p }}
{{ form.media }}
<button type="submit">Submit</button>
</form>
The same is true also, if you are rendering the forms field manually.
Django Prose can also handle uploading attachments with drag and drop. To set this up, first you need to:
[x] Set up the MEDIA_ROOT
and MEDIA_URL
of your Django project (example in example/example/settings.py
))
[x] Include the Django Prose URLs (example in example/example/urls.py
)
[x] (Optional) Set up a different Django storage to store your files (e.g. S3)
Attachments are uploaded with a path structure of /YEAR/MONTH/DATE/UUID.EXT
By default, only files 5MB or less are allowed.
Allowed file size can be overridden by setting PROSE_ATTACHMENT_ALLOWED_FILE_SIZE
in your Django project's settings file.
# File size in megabytes
PROSE_ATTACHMENT_ALLOWED_FILE_SIZE = 15
You can find a full example of a blog, built with Django Prose in the example
directory.
As you can see in the examples above, what Django Prose does is provide you with a user friendly editor (Trix) for your rich text content and then store it as HTML in your database. Since you will mark this HTML as safe in order to use it in your templates, it needs to be sanitised, before it gets stored in the database.
For this reason Django Prose is using Bleach to only allow the following tags and attributes:
p
, ul
, ol
, li
, strong
, em
, div
, span
, a
, blockquote
, pre
, figure
, figcaption
, br
, code
, h1
, h2
, h3
, h4
, h5
, h6
, picture
, source
, img
alt
, class
, id
, src
, srcset
, href
, media
If you are more of a video person, you can watch our video showcasing how to Create a blog using Django Prose on YouTube
If you are using Django Prose in your application too, feek free to open a Pull Request to include it here. We would love to have it.
If you plan to contribute code to Django Prose, this section is for you. All development tooling for Django Prose has been set up with Docker and Development Containers.
To get started run these commands in the provided order:
docker compose run --rm migrate
docker compose run --rm createsuperuser
docker compose up
If you are using Visual Studio code, just open this repository in a container using the Dev Containers: Open Folder in Container
.
Built with LOGIC.