Front end editing for Django.
Project description
Django-Front-Edit
Description
A front end editing app for Django. This app allows one to edit dynamic data on the front end of a website when logged in as a staff member. The app allows the editing of dynamic content within any element (See Example below).
Installation
You must have setuptools installed.
From PyPI:
pip install django_front_edit
Or download a package from the PyPI or the BitBucket page:
pip install <package>
Or unpack the package and:
python setup.py install.
Dependencies
Django >= 1.4 and its dependencies.
beautifulsoup4 >= 4.3.2 located at: http://www.crummy.com/software/BeautifulSoup/ or https://pypi.python.org/pypi/beautifulsoup4/.
django-classy-tags >= 0.5.1 located at: https://github.com/ojii/django-classy-tags or https://pypi.python.org/pypi/django-classy-tags.
Integration
In your Django settings.py file insert the following in an appropriate place:
... TEMPLATE_CONTEXT_PROCESSORS = [ 'django.contrib.auth.context_processors.auth', ... 'django.core.context_processors.request', ... 'front_edit.context_processors.defer_edit' ] ... INSTALLED_APPS = [ ... "front_edit", ... ] ...
In your main urls.py file:
... url(r'', include('front_edit.urls')), ...
There is nothing to syncdb or migrate.
Usage
This app uses template tags for all its functionality.
JavaScript
There is one command that you can call if you need to reposition the edit elements. You should call this if any JavaScript will change the offset of in-flow elements.
$.front_edit('refresh');
Example
{% load front_edit_tags %} <!DOCTYPE html> <html> <head></head> <body> <div> <!-- In a list --> <ul> {% for object in objects %} {% edit object.text_field object.char_field "class_name" %} <li> <span>{{ object.text_field }}</span> <span>{{ object.char_field }}</span> </li> {% endedit %} {% endfor %} </ul> <!-- In a table --> <table> <tbody> <tr> {% for object in objects %} {% edit object.text_field object.char_field "class_name" %} <td> <span>{{ object.text_field }}</span> <span>{{ object.char_field }}</span> </td> {% endedit %} {% endfor %} </tr> </tbody> </table> </div> <div> <!-- On a span --> {% edit object.text_field "class_name" %} <span>{{ object.text_field }}</span> {% endedit %{ </div> {% edit_loader %} </body> </html>
Advanced
Settings
FRONT_EDIT_LOGOUT_URL_NAME
Default: “admin:logout”
Set the name of the logout url.
FRONT_EDIT_CUSTOM_FIELDS
Default: []
A list of dot-separated paths to a custom model field such as a rich text field or file field that has a Media class on its widget.
FRONT_EDIT_INLINE_EDITING_ENABLED
Default: True
Option to disable inline editing.
FRONT_EDIT_LOADER_TEMPLATE
Default:’front_edit/loader.html’
This template is the main boilerplate.
FRONT_EDIT_TOOLBAR_TEMPLATE
Default: ‘front_edit/includes/toolbar.html’
This template is the admin toolbar.
FRONT_EDIT_EDITABLE_TEMPLATE
Default: ‘front_edit/includes/editable.html’
This template is the editable. Which includes the form, edit button, and overlay.
Custom Media and JS variables
If the FRONT_EDIT_CUSTOM_FIELDS setting doesn’t satisfy your needs you will need to do the following.
Change FRONT_EDIT_LOADER_TEMPLATE to your own template, it should have a different name than ‘front_edit/loader.html’.
In your template extend ‘front_edit/loader.html’.
Use the block ‘ft_extra’ to set or run javascript code. No script tags are needed.
Use the block ‘ft_extra_media’ to define media such as CSS or JS files.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.