Skip to main content

Integrate Quill editor with Django project.

Project description

django-quill-editor

django-quill-editor makes Quill.js easy to use on Django Forms and admin sites

  • No configuration required for static files!
  • The entire code for inserting WYSIWYG editor is less than 30 lines
  • It can be used in both admin and Django views

django-quill-editor

Setup

  • Install django-quill-editor to your Python environment

    pip install django-quill-editor
    
  • Add django_quill to INSTALLED_APPS in settings.py

    # settings.py
    INSTALLED_APPS = [
        'django.contrib.admin',
        ...
        'django_quill',
    ]
    

Run Sample project

# Clone repo, move to sample project
git clone https://github.com/LeeHanYeong/django-quill-editor
cd django-quill-editor/sample

# Create virtualenv (I used pyenv, but you can use other methods)
pyenv virtualenv 3.7.5 django-quill
pyenv local django-quill

# Install Python packages
pip install -r requirements.txt
python manage.py runserver

Usage

Add QuillField to the Model class you want to use

# models.py
from django.db import models
from django_quill.fields import QuillField

class QuillPost(models.Model):
    content = QuillField()

1. Django admin

Just register the Model in admin.py of the app.

from django.contrib import admin
from .models import QuillPost

@admin.register(QuillPost)
class QuillPostAdmin(admin.ModelAdmin):
    pass

admin-sample

2. Form

  • Add QuillFormField to the Form class you want to use

  • There are two ways to add CSS and JS files to a template.

    • If there is a Form with QuillField added, add {{ form.media }} to the <head> tag.

      <head>
          {{ form.media }}
      </head>
      
    • Or, import CSS and JS files directly using {% include %} template tags.

      <head>
          <!-- django-quill-editor Media -->
          {% include 'django_quill/media.html' %}
      </head>
      
# forms.py
from django import forms
from django_quill.forms import QuillFormField

class QuillFieldForm(forms.Form):
    content = QuillFormField()
# views.py
from django.shortcuts import render
from .forms import QuillFieldForm

def form(request):
    return render(request, 'form.html', {'form': QuillFieldForm()})
<!-- Template -->
<form action="" method="POST">{% csrf_token %}
    {{ form.content }}
</form>

3. ModelForm

Just define and use ModelForm of Model class

# forms.py
from django import forms
from .models import QuillPost

class QuillPostForm(forms.ModelForm):
    class Meta:
        model = QuillPost
        fields = (
            'content',
        )
# views.py
from django.shortcuts import render
from .forms import QuillPostForm

def model_form(request):
    return render(request, 'model_form.html', {'form': QuillPostForm()})
<!-- Template -->
<form action="" method="POST">{% csrf_token %}
    {{ form.content }}
</form>

Form, ModelForm's Output:

form-sample

Contributing

As an open source project, we welcome contributions. The code lives on GitHub

Project details


Download files

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

Source Distribution

django-quill-editor-0.1.4.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_quill_editor-0.1.4-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file django-quill-editor-0.1.4.tar.gz.

File metadata

  • Download URL: django-quill-editor-0.1.4.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

File hashes

Hashes for django-quill-editor-0.1.4.tar.gz
Algorithm Hash digest
SHA256 ca9758f2338317d1143bcb37b05e991efe504e85a5c55617a8be9b2967032a37
MD5 9772e3faa23503204ccae38473109801
BLAKE2b-256 6dbec02d446ede5d3c0525f80a98954432657540d2a38fbdf3cdf9ee52d4206c

See more details on using hashes here.

File details

Details for the file django_quill_editor-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: django_quill_editor-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.1

File hashes

Hashes for django_quill_editor-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 7a2e66fb295571ac042c6af8719cb80afa4e1032769d1a2c2857a715ba74ef57
MD5 1b6d473dd54b2022ec7eab97e6df14cb
BLAKE2b-256 fbc62857c4cb9a48ce257e0f62ec5c5da6066ae2b4fda86a15dcaa506d117058

See more details on using hashes here.

Supported by

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