Introduction¶
django-inline-media allows insertion of inline media content in your text fields. Based on django-basic-apps/inlines, it provives the following features:
- Inserts pictures and collection of pictures into your texts using the
TextAreaWithInlines
widget. - Positions media content at different places and sizes (mini/small/medium/large at left/right or full at the left/center/right).
- Facilitates administration with thumbnails and search by tags, author and license.
- Shows a customised control to insert media content in text fields.
- Uses jquery prettyPhoto to show pictures and galleries when clicking on them.
- Tested under:
- Python 2.7 and Python 3 (3.2, 3.4, 3.5, 3.6)
- Django 1.8, Django 1.9 and Django 1.10
The following sample shows a centered inline picture set inserted in a text, on mouseover event the first 3 photos unfold:
Run the demo project to see django-inline-media in action.
Quick start¶
Get the dependencies:
$ pip install -r requirements.pip
In your
settings.py
:
- Add
inline_media
,sorl.thumbnail
andtagging
toINSTALLED_APPS
. - Add
THUMBNAIL_BACKEND = "inline_media.sorl_backends.AutoFormatBackend"
- Add
THUMBNAIL_FORMAT = "JPEG"
- Create a model with a field of type
TextFieldWithInlines
. - Create an admin class for that model by inheriting from both
inline_media.admin.AdminTextFieldWithInlinesMixin
and Django’sadmin.ModelAdmin
. - Optionally, customise inline_media templates by copying them from
inline_media/templates/inline_media/
to yourinline_media/
folder in your templates directory.
- Run
manage.py
commands:syncdb
,collectstatic
,runserver
. - Create two InlineType objects, one for the Picture model and one for the PictureSet model.
- Upload some pictures and create some picture sets.
- Add content to the model using the field
TextFieldWithInlines
and see that you can insert inline content in the textarea. It will be rendered in the position indicated by the CSS class selected in the dropdown box. - Hit your app’s URL!
Run the demo in django-inline-media/examples/demo
to see an example.