Giter Club home page Giter Club logo

django-quill's Introduction

django-quill

Build Status Latest Version

Easily use Quill.js in your django admin.

This project is heavily inspired by django-ckeditor.

Requires django 1.7.

Admin Preview

Quick start

  1. Install the package from pypi

    pip install django-quill
  2. Add "quill" to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = (
        ...
        'quill',
    )

Usage

from django.db import models
from quill.fields import RichTextField


class MyModel(models.Model):
    content = RichTextField()
    content2 = RichTextField(config='basic')

If you want to support image uploads, your admin needs to extend from quill.admin.QuillAdmin:

from quill.admin import QuillAdmin

class MyAdmin(QuillAdmin):
    pass

Customizing

To customize this app, extend apps.QuillConfig and modify whatever you need. For example, to add a new toolbar:

from quill.apps import QuillConfig


class MyQuillConfig(QuillConfig):
    my_toolbar = dict(full, toolbar_template='quill/toolbars/my_toolbar.html')

To customize the extensions of the images that can be uploaded:

from quill.apps import QuillConfig


class MyQuillConfig(QuillConfig):
    allowed_image_extensions = ['jpeg', 'gif']

If you need to call other methods or perform additional actions on the quill editors, they will be available in window.DjangoQuillEditors.

Provided Toolbars

There are two toolbars that come with this package:

  1. Full (default): Provides basic font style and size selection, bold, italics, underline, strikethrough, text color, background color, lists, links, and images.
  2. Basic: Provides bold, italic, underline, lists, and links.

Development

There are several dependencies on npm that are required before building django-quill:

$ npm install

Auto Compile JS

$ make watch

Running Tests

$ make test

Building JS

$ make build

TODO

  1. Better documentation.
  2. More tests.
  3. Better support for using outside of the admin.

django-quill's People

Contributors

rsenk330 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

django-quill's Issues

Make all created editors globally available

It would be nice to have access to any Quill editors after they are created, for calling their methods etc.

I've solved this by creating my own app config with its own widget template that has these extra lines after instantiating the editor:

var editor = new QuillDjango(id, editorSelector, toolbarSelector, imageModuleOpts, theme);
window.DjangoQuillEditors = window.DjangoQuillEditors || {};
window.DjangoQuillEditors[id] = editor;
var form = document.querySelector('form');

Now I can get at an editor using the original element id as key:

var editor = window.DjangoQuillEditors.id_body.quill;
// ...do stuff with the editor object.

Is this feature interesting enough to include in django-quill? If so, let me know and I'll open a proper pull request for it.

Integrating Table in Editor

Hey,
How do we create tables in the editor itself? Also, copying pasting tables from third-party sources is not working well.

Error when pip installing

I can't seem to install this using pip. It complains about not being able to find the DESCRIPTION.rst file. Is this happening for anyone else?

Collecting django-quill
  Using cached django-quill-0.1.0.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/44/97sht4l92c5560jwvlsnm0c80000gn/T/pip-build-A2WfHB/django-quill/setup.py", line 9, in <module>
        with open(os.path.join(here, 'DESCRIPTION.rst'), encoding='utf-8') as f:
      File "/Users/lukecaldwell/Documents/Repos/web/project/venv/lib/python2.7/codecs.py", line 884, in open
        file = __builtin__.open(filename, mode, buffering)
    IOError: [Errno 2] No such file or directory: '/private/var/folders/44/97sht4l92c5560jwvlsnm0c80000gn/T/pip-build-A2WfHB/django-quill/DESCRIPTION.rst'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/44/97sht4l92c5560jwvlsnm0c80000gn/T/pip-build-A2WfHB/django-quill/

getattr(): attribute name must be string

I'm trying to get a very basic example running on django 1.7.1 as per the first usage example in the README, and I get the following error:

TypeError at /admin/page/page/1/
getattr(): attribute name must be string
Request Method: GET
Request URL:    http://10.0.0.3:8000/admin/page/page/1/
Django Version: 1.7.4
Exception Type: TypeError
Exception Value:    
getattr(): attribute name must be string
Exception Location: ./env/local/lib/python2.7/site-packages/quill/widgets.py in render, line 43

It's dying on this line in widgets.py:

quill_config = getattr(quill_app, self.config)

If I log the value of self.config I get a proxy object (<django.utils.functional.__proxy__ object at 0x3807f90>) instead of a string as I presume is expected.

If I dump the dict of the object, I get:

{'_proxy____args': ('content',), '_proxy____kw': {}}

The proxy objects are usually used for lazy string translation, and passing it through unicode() will get the value back, but in this case the value translates to 'content' (the name of the model field) instead of 'default' as expected.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.