Django Writingfield

Django writing field is a custom form widget to enhance textareas in the django admin to give them a delicious fullscreen writing mode.

Features

  • Ajax save so you don’t have to lose your focus - ctrl/command + s

Installation

Install django-writingfield

pip install django-writingfield

Add writingfield to your INSTALLED_APPS

# yourproject/settings.py
INSTALLED_APPS = (
    #...
    'writingfield',
)

Run the collectstatic command to get the staticmedia

python manage.py collectstatic

Note

If you’re not using the staticfiles app, then you’ll have to manually copy the media to a place where you’ll be able to access the files from the writingfield/static/writingfield directory.

Add the middleware to stop django.contrib.messages building up in the background

MIDDLEWARE_CLASSES = (
    # writing field must come BEFORE MessageMiddleware
    'writingfield.middleware.WritingFieldMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
),

Note

The writingfield.middleware.WritingFieldMiddleware must come before django.contrib.messages.middleware.MessageMiddleware or you’ll still experience the build up of django.contrib.messages.

Getting Started

Write a form that you can use in your ModelAdmin, for example –

# yourapp/forms.py
from writingfield.widgets import FullScreenTextarea

class YourAdminForm(forms.ModelForm):

    class Meta:
        widgets = {
        'mytextarea': FullScreenTextarea()
    }

Warning

In versions previous to 1.1.8 FullScreenTextarea could be imported from writingfield. This will continue to work until version 1.2

Now that you have the form, you need to tell your ModelAdmin class to use it –

# yourapp/admin.py
from yourapp.forms import YourAdminForm
from yourapp.models import YourModel

class YourModelAdminClass(admin.ModelAdmin):
    form = YourAdminForm
    # other admin stuff

admin.site.register(YourModel, YourModelAdminClass)

Issues

Report all issues to the django-writingfield issues page on github.

License

django-writingfield is released under a BSD 3 clause license

Copyright © 2014, Obscure Metaphor LTD. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the Obsure Metaphor LTD nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.