django-ajaximage 0.2.8

Upload images via ajax. Images are optionally resized.
django-ajaximage
===============

Ajax image uploads.
-------------------------------------

[![PyPi Version](https://pypip.in/v/django-ajaximage/badge.png)](https://crate.io/packages/django-ajaximage)
[![PyPi Downloads](https://pypip.in/d/django-ajaximage/badge.png)](https://crate.io/packages/django-ajaximage)

Upload images via ajax. Images are optionally resized.

![screenshot](https://raw.githubusercontent.com/bradleyg/django-ajaximage/master/screenshot.png)

## Support
Python 2/3
Chrome / Safari / Firefox / IE10+

For older browser support use version 0.1.18.

## Installation

Install with Pip:

```pip install django-ajaximage```

## Django Setup

### settings.py

```python
INSTALLED_APPS = [
    ...
    'ajaximage',
    ...
]

# Settings
AJAXIMAGE_AUTH_TEST = lambda u: True
```

### urls.py

```python
urlpatterns = patterns('',
    url(r'^ajaximage/', include('ajaximage.urls')),
)
```

Run ```python manage.py collectstatic``` if required.

## Use in Django admin only

### models.py

```python
from django.db import models
from ajaximage.fields import AjaxImageField

class Example(models.Model):
    thumbnail = AjaxImageField(upload_to='thumbnails',
                               max_height=200, #optional
                               max_width=200, # optional
                               crop=True) # optional

# if crop is provided both max_height and max_width are required
```

## Use the widget in a custom form

### forms.py

```python
from django import forms
from ajaximage.widgets import AjaxImageWidget

class AjaxImageUploadForm(forms.Form):
    images = forms.URLField(widget=AjaxImageWidget(upload_to='form-uploads'))
```

### views.py

```python
from django.views.generic import FormView
from .forms import AjaxImageUploadForm

class MyView(FormView):
    template_name = 'form.html'
    form_class = AjaxImageUploadForm
```

### templates/form.html

```html
<html>
<head>
    <meta charset="utf-8">
    <title>ajaximage</title>
    {{ form.media }}
</head>
<body>
    {{ form.as_p }}
</body>
</html>
```

## Examples
Examples of both approaches can be found in the examples folder. To run them:
```shell
$ git clone git@github.com:bradleyg/django-ajaximage.git
$ cd django-ajaximage
$ python setup.py install
$ cd example

$ python manage.py syncdb
$ python manage.py runserver 0.0.0.0:5000
```

Visit ```http://localhost:5000/admin``` to view the admin widget and ```http://localhost:5000/form``` to view the custom form widget.

Author

Bradley Griffiths

Pip

django-ajaximage==0.2.8

Classifiers

  • Environment :: Web Environment
  • Framework :: Django
  • Intended Audience :: Developers
  • License :: OSI Approved :: MIT License
  • Operating System :: OS Independent
  • Programming Language :: Python :: 2.7
  • Development Status :: 4 - Beta
  • Programming Language :: Python :: 3.4
File Type Python Version Uploaded On Downloads
django-ajaximage-0.2.8.tar.gz Source April 6, 2015 1,636
Version Release Date
0.2.8 April 6, 2015
0.2.7 Oct. 7, 2014
0.2.6 Oct. 7, 2014
0.2.5 Oct. 7, 2014
0.2.4 Oct. 7, 2014
0.2.3 Oct. 7, 2014
0.2.2 Oct. 7, 2014
0.2.1 Oct. 7, 2014
0.2.0 Oct. 7, 2014
0.1.18 May 6, 2014
0.1.17 Feb. 22, 2014
0.1.16 Dec. 12, 2013
0.1.15 Aug. 21, 2013
0.1.14 May 27, 2013
0.1.13 April 16, 2013
0.1.12 April 2, 2013
0.1.11 March 15, 2013
0.1.10 March 15, 2013
0.1.9 March 14, 2013
0.1.8 March 14, 2013
0.1.7 March 14, 2013
0.1.6 March 14, 2013
0.1.5 March 13, 2013
0.1.4 March 13, 2013
0.1.3 March 13, 2013
0.1.2 March 13, 2013
0.1.1 March 13, 2013
Date Package Version Action
Aug. 24, 2015, 10:58 p.m. django-ajaximage 0.1.8 Release Created
Aug. 24, 2015, 10:58 p.m. django-ajaximage 0.1.18 Release Created
Aug. 24, 2015, 10:58 p.m. django-ajaximage 0.1.15 Release Created
Aug. 24, 2015, 10:58 p.m. django-ajaximage 0.1.14 Release Created
Aug. 24, 2015, 10:58 p.m. django-ajaximage 0.1.17 Release Created
Aug. 24, 2015, 10:58 p.m. django-ajaximage 0.1.16 Release Created
Aug. 24, 2015, 10:58 p.m. django-ajaximage 0.1.11 Release Created
Aug. 24, 2015, 10:58 p.m. django-ajaximage 0.1.10 Release Created
Aug. 24, 2015, 10:58 p.m. django-ajaximage 0.1.13 Release Created
Aug. 24, 2015, 10:58 p.m. django-ajaximage 0.1.12 Release Created
Aug. 24, 2015, 10:58 p.m. django-ajaximage 0.1.9 Release Created
Aug. 24, 2015, 10:58 p.m. django-ajaximage 0.2.8 Release Created
Aug. 24, 2015, 10:58 p.m. django-ajaximage 0.1.7 Release Created
Aug. 24, 2015, 10:58 p.m. django-ajaximage 0.1.6 Release Created
Aug. 24, 2015, 10:58 p.m. django-ajaximage 0.1.5 Release Created
Aug. 24, 2015, 10:58 p.m. django-ajaximage 0.1.4 Release Created
Aug. 24, 2015, 10:58 p.m. django-ajaximage 0.1.3 Release Created
Aug. 24, 2015, 10:58 p.m. django-ajaximage 0.1.2 Release Created
Aug. 24, 2015, 10:58 p.m. django-ajaximage 0.1.1 Release Created
Aug. 24, 2015, 10:58 p.m. django-ajaximage 0.2.0 Release Created
Aug. 24, 2015, 10:58 p.m. django-ajaximage 0.2.1 Release Created
Aug. 24, 2015, 10:58 p.m. django-ajaximage 0.2.2 Release Created
Aug. 24, 2015, 10:58 p.m. django-ajaximage 0.2.3 Release Created
Aug. 24, 2015, 10:58 p.m. django-ajaximage 0.2.4 Release Created
Aug. 24, 2015, 10:58 p.m. django-ajaximage 0.2.5 Release Created
Aug. 24, 2015, 10:58 p.m. django-ajaximage 0.2.6 Release Created
Aug. 24, 2015, 10:58 p.m. django-ajaximage 0.2.7 Release Created
Aug. 24, 2015, 10:58 p.m. django-ajaximage Package Created