How to Begin Using Django InPlace Edit App

by Applied Informatics

Inplace Edit Form is a Django application that allows you to inline edition of some data from the database.

With django inplace edit, a user can edit fields in a django template without needing to be redirected to another page for editing. This app provides user the ease of editing fields from front end and new edited fields will be saved in the database.

Screenshot

Using inplace_edit tag you can inplace edit any data from database. The inline edition is not only for text fields, you can also have inline edition for choices, boolean fields, date and date/time fields, foreing keys, many to many, file and image fields.

In template file:

{% inplace_edit "OBJ.FIELD_NAME" %}
{% inplace_edit "OBJ.FIELD_NAME|FILTER1|FILTER2|...|FILTERN" %}

Example:Normally we write code in template like this:

<span>{{ user.name }}</span>
<span>{{ user.email }}</span>

In order to use in line change the above code to this:

<span>{% inplace_edit "user.name" %}</span>
<span>{% inplace_edit "user.email" %}</span>

Installation

You need to install django-inplaceedit.

Also do remember to include latest jquery in your base template.

After installing the above app inside your project environment, in your settings.py include ‘inplaceeditform’ inside installed apps.

INSTALLED_APPS = (
'inplaceeditform',
)

Also if request context processor is commented, uncomment it.

TEMPLATE_CONTEXT_PROCESSORS = (
#...#
'django.core.context_processors.request',
#...#
)

then in urls.py

urlpatterns = patterns('',

#…#

(r’^inplaceeditform/’, include(‘inplaceeditform.urls’)),

#…#
)

And then in your Base template, Add this:

{% load inplace_edit %}

and wherever you load your static files, add either

{% inplace_toolbar %}

or

{% inplace_static %}

An Example to demonstrate the usage in a single template:

{% load inplace_edit %}
<html>
<head>
...
<script src="{{ STATIC_URL }}js/jquery.min.js" type="text/javascript"></script>
{% inplace_static %}
</head>
<body>
...
<div id="content">
...
{% inplace_edit "content.name" %}
...
<div class="description">
{% inplace_edit "content.date_initial|date:'d m Y'" %}
{% inplace_edit "content.description|safe" %}
</div>
<div class="body">
{% inplace_edit "content.body|safe|truncatewords_html:15" %}
</div>
</div>
...
</body>
</html>

Thats how easy it is to get the inplaceedit app from django up and running. And now you will be able to edit fields of your template from the front end. Django inplaceedit can be integrated with bootstrap also, for that you need to install “django-inplaceedit-bootstrap” and then include ‘inplaceeditform_bootstrap’ in installed apps of your settings.py.

Django-inplaceedit is generic, customizable, and extensible.

To learn more about

Contact Us

2 thoughts on “How to Begin Using Django InPlace Edit App”

Leave a Reply to thomas Cancel reply

Your email address will not be published. Required fields are marked *

Tools & Practices

Tools and Technologies we use at Applied

Contact us now

Popular Posts