django-image-uploader-widget


Namedjango-image-uploader-widget JSON
Version 0.5.0 PyPI version JSON
download
home_pageNone
SummarySimple Image Uploader Widget for Django-Admin
upload_time2024-04-03 11:48:56
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
licenseMIT License Copyright (c) 2021 Eduardo José de Oliveira Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords django admin widget image uploader
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <h1 align="center">django-image-uploader-widget</h1>

<p align="center">
    <img src="https://raw.githubusercontent.com/inventare/django-image-uploader-widget/main/docs/_images/behaviour_inline.gif" />
</p>

<p align="center">
    <img alt="Supported Python Versions" src="https://img.shields.io/badge/Python-3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue" />
    <img alt="Supported Django Versions" src="https://img.shields.io/badge/Django-3.2%20|%204.0%20|%204.1%20|%204.2%20|%205.0-blue" />
    <img alt="PyPI - Version" src="https://img.shields.io/pypi/v/django-image-uploader-widget" />
    <img alt="GitHub License" src="https://img.shields.io/github/license/inventare/django-image-uploader-widget" />
    <img alt="PyPI - Downloads" src="https://img.shields.io/pypi/dm/django-image-uploader-widget" />
    <img alt="GitHub Actions Workflow Status" src="https://img.shields.io/github/actions/workflow/status/inventare/django-image-uploader-widget/test.yml?label=tests" />
</p>

## Introduction

`django-image-uploader-widget` provides a beautiful image uploader widget for **django** and a multiple image inline editor for **django-admin**.

## Requirements

- Python 3.8+
- Django 3.2+

## Features

- [x] Support required and optional `ImageField`;
- [x] Support for `ImageField` inside inlines **django-admin**;
- [x] Support preview modal;
- [x] Support custom inline for **django-admin** usage.
- [x] Support reordering inside **django-admin** inline.
- [x] Support `ArrayField` for `PostgreSQL` databases.

## Installation

Install from PyPI:

```bash
pip install django-image-uploader-widget
```

Add `image_uploader_widget` to `INSTALLED_APPS`:

```python
INSTALLED_APPS = [
    # ...
    'image_uploader_widget',
    # ...
]
```

## Basic Usage

### With Admin

The `ImageUploaderWidget` is a class that implements a custom widget for single image uploader and can be used inside the `formfield_overrides` attribute inside the `ModelAdmin` class.

```python
# admin.py
from django.contrib import admin
from django.db import models
from image_uploader_widget.widgets import ImageUploaderWidget
from .models import YourModel


@admin.register(YourModel)
class YourModelAdmin(admin.ModelAdmin):
    formfield_overrides = {
        models.ImageField: {'widget': ImageUploaderWidget},
    }
```

See the [documentation](https://inventare.github.io/django-image-uploader-widget/widget/resumed/) for more complex usage's.

### With ModelForm

The `ImageUploaderWidget` can be used inside the `widgets` Meta attribute of a `Form`/`ModelForm`:

```python
# forms.py
from django import forms
from image_uploader_widget.widgets import ImageUploaderWidget

class ExampleForm(forms.ModelForm):
    class Meta:
        widgets = {
            'image': ImageUploaderWidget(),
        }
        fields = '__all__'
```

See the [documentation](https://inventare.github.io/django-image-uploader-widget/widget/resumed/) for more complex usage's.

### Custom Inline Admin

The `ImageUploaderInline` is implemented with the base of the `admin.StackedInline` to create an custom **django-admin** to work with multiple images upload using a model only to store the images:

```python
# models.py

class Product(models.Model):
    # ...

class ProductImage(models.Model):
    product = models.ForeignKey(
        Product,
        related_name="images",
        on_delete=models.CASCADE
    )
    image = models.ImageField("image")
    # ...
```

```python
# admin.py
from django.contrib import admin
from image_uploader_widget.admin import ImageUploaderInline
from .models import Product, ProductImage

class ProductImageAdmin(ImageUploaderInline):
    model = ProductImage

@admin.register(Product)
class ProductAdmin(admin.ModelAdmin):
    inlines = [ProductImageAdmin]
```

See the [documentation](https://inventare.github.io/django-image-uploader-widget/inline_admin/tutorial/) for more complex usage's.

### Array Field

The ArrayField support is made by a custom field, called `ImageListField`. Then, to use it, we need to change the field from default `ArrayField` to `ImageListField`. The reason for it is: the default `ArrayField` with `ImageField` not works and some part of the behaviour of the `ImageField` is implemented inside the `ImageListField`.

```python
# models.py
from django.db import models
from image_uploader_widget.postgres import ImageListField

class TestWithArrayField(models.Model):
    images = ImageListField(blank=True, null=True, upload_to="admin_test")

    class Meta:
        verbose_name = "Test With Array Field"
```

See the [documentation](https://inventare.github.io/django-image-uploader-widget/array_field/tutorial/) for more complex usage's.

## Documentation

All the documentation of basic and advanced usage of this package is disponible at [documentation](https://inventare.github.io/django-image-uploader-widget/).

## Preview

![Widget with Image in Dark Theme](https://raw.githubusercontent.com/inventare/django-image-uploader-widget/main/docs/_images/widget_image_dark.png#gh-dark-mode-only)![Widget with Image in Light Theme](https://raw.githubusercontent.com/inventare/django-image-uploader-widget/main/docs/_images/widget_image.png#gh-light-mode-only)

![Widget in Dark Theme](https://raw.githubusercontent.com/inventare/django-image-uploader-widget/main/docs/_images/widget_dark.png#gh-dark-mode-only)![Widget in Light Theme](https://raw.githubusercontent.com/inventare/django-image-uploader-widget/main/docs/_images/widget.png#gh-light-mode-only)

## Behaviour

![Widget Behaviour](https://raw.githubusercontent.com/inventare/django-image-uploader-widget/main/docs/_images/behaviour_widget.gif)

![Custom Admin Inline Behaviour](https://raw.githubusercontent.com/inventare/django-image-uploader-widget/main/docs/_images/behaviour_inline.gif)

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "django-image-uploader-widget",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "Eduardo Oliveira <eduardo_y05@outlook.com>",
    "keywords": "django, admin, widget, image, uploader",
    "author": null,
    "author_email": "Eduardo Oliveira <eduardo_y05@outlook.com>",
    "download_url": "https://files.pythonhosted.org/packages/78/05/bbf28cdb6d701d441e80dfcc40cbead1ca1287ead5e80741c5aca1c12e6b/django-image-uploader-widget-0.5.0.tar.gz",
    "platform": null,
    "description": "<h1 align=\"center\">django-image-uploader-widget</h1>\n\n<p align=\"center\">\n    <img src=\"https://raw.githubusercontent.com/inventare/django-image-uploader-widget/main/docs/_images/behaviour_inline.gif\" />\n</p>\n\n<p align=\"center\">\n    <img alt=\"Supported Python Versions\" src=\"https://img.shields.io/badge/Python-3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11%20%7C%203.12-blue\" />\n    <img alt=\"Supported Django Versions\" src=\"https://img.shields.io/badge/Django-3.2%20|%204.0%20|%204.1%20|%204.2%20|%205.0-blue\" />\n    <img alt=\"PyPI - Version\" src=\"https://img.shields.io/pypi/v/django-image-uploader-widget\" />\n    <img alt=\"GitHub License\" src=\"https://img.shields.io/github/license/inventare/django-image-uploader-widget\" />\n    <img alt=\"PyPI - Downloads\" src=\"https://img.shields.io/pypi/dm/django-image-uploader-widget\" />\n    <img alt=\"GitHub Actions Workflow Status\" src=\"https://img.shields.io/github/actions/workflow/status/inventare/django-image-uploader-widget/test.yml?label=tests\" />\n</p>\n\n## Introduction\n\n`django-image-uploader-widget` provides a beautiful image uploader widget for **django** and a multiple image inline editor for **django-admin**.\n\n## Requirements\n\n- Python 3.8+\n- Django 3.2+\n\n## Features\n\n- [x] Support required and optional `ImageField`;\n- [x] Support for `ImageField` inside inlines **django-admin**;\n- [x] Support preview modal;\n- [x] Support custom inline for **django-admin** usage.\n- [x] Support reordering inside **django-admin** inline.\n- [x] Support `ArrayField` for `PostgreSQL` databases.\n\n## Installation\n\nInstall from PyPI:\n\n```bash\npip install django-image-uploader-widget\n```\n\nAdd `image_uploader_widget` to `INSTALLED_APPS`:\n\n```python\nINSTALLED_APPS = [\n    # ...\n    'image_uploader_widget',\n    # ...\n]\n```\n\n## Basic Usage\n\n### With Admin\n\nThe `ImageUploaderWidget` is a class that implements a custom widget for single image uploader and can be used inside the `formfield_overrides` attribute inside the `ModelAdmin` class.\n\n```python\n# admin.py\nfrom django.contrib import admin\nfrom django.db import models\nfrom image_uploader_widget.widgets import ImageUploaderWidget\nfrom .models import YourModel\n\n\n@admin.register(YourModel)\nclass YourModelAdmin(admin.ModelAdmin):\n    formfield_overrides = {\n        models.ImageField: {'widget': ImageUploaderWidget},\n    }\n```\n\nSee the [documentation](https://inventare.github.io/django-image-uploader-widget/widget/resumed/) for more complex usage's.\n\n### With ModelForm\n\nThe `ImageUploaderWidget` can be used inside the `widgets` Meta attribute of a `Form`/`ModelForm`:\n\n```python\n# forms.py\nfrom django import forms\nfrom image_uploader_widget.widgets import ImageUploaderWidget\n\nclass ExampleForm(forms.ModelForm):\n    class Meta:\n        widgets = {\n            'image': ImageUploaderWidget(),\n        }\n        fields = '__all__'\n```\n\nSee the [documentation](https://inventare.github.io/django-image-uploader-widget/widget/resumed/) for more complex usage's.\n\n### Custom Inline Admin\n\nThe `ImageUploaderInline` is implemented with the base of the `admin.StackedInline` to create an custom **django-admin** to work with multiple images upload using a model only to store the images:\n\n```python\n# models.py\n\nclass Product(models.Model):\n    # ...\n\nclass ProductImage(models.Model):\n    product = models.ForeignKey(\n        Product,\n        related_name=\"images\",\n        on_delete=models.CASCADE\n    )\n    image = models.ImageField(\"image\")\n    # ...\n```\n\n```python\n# admin.py\nfrom django.contrib import admin\nfrom image_uploader_widget.admin import ImageUploaderInline\nfrom .models import Product, ProductImage\n\nclass ProductImageAdmin(ImageUploaderInline):\n    model = ProductImage\n\n@admin.register(Product)\nclass ProductAdmin(admin.ModelAdmin):\n    inlines = [ProductImageAdmin]\n```\n\nSee the [documentation](https://inventare.github.io/django-image-uploader-widget/inline_admin/tutorial/) for more complex usage's.\n\n### Array Field\n\nThe ArrayField support is made by a custom field, called `ImageListField`. Then, to use it, we need to change the field from default `ArrayField` to `ImageListField`. The reason for it is: the default `ArrayField` with `ImageField` not works and some part of the behaviour of the `ImageField` is implemented inside the `ImageListField`.\n\n```python\n# models.py\nfrom django.db import models\nfrom image_uploader_widget.postgres import ImageListField\n\nclass TestWithArrayField(models.Model):\n    images = ImageListField(blank=True, null=True, upload_to=\"admin_test\")\n\n    class Meta:\n        verbose_name = \"Test With Array Field\"\n```\n\nSee the [documentation](https://inventare.github.io/django-image-uploader-widget/array_field/tutorial/) for more complex usage's.\n\n## Documentation\n\nAll the documentation of basic and advanced usage of this package is disponible at [documentation](https://inventare.github.io/django-image-uploader-widget/).\n\n## Preview\n\n![Widget with Image in Dark Theme](https://raw.githubusercontent.com/inventare/django-image-uploader-widget/main/docs/_images/widget_image_dark.png#gh-dark-mode-only)![Widget with Image in Light Theme](https://raw.githubusercontent.com/inventare/django-image-uploader-widget/main/docs/_images/widget_image.png#gh-light-mode-only)\n\n![Widget in Dark Theme](https://raw.githubusercontent.com/inventare/django-image-uploader-widget/main/docs/_images/widget_dark.png#gh-dark-mode-only)![Widget in Light Theme](https://raw.githubusercontent.com/inventare/django-image-uploader-widget/main/docs/_images/widget.png#gh-light-mode-only)\n\n## Behaviour\n\n![Widget Behaviour](https://raw.githubusercontent.com/inventare/django-image-uploader-widget/main/docs/_images/behaviour_widget.gif)\n\n![Custom Admin Inline Behaviour](https://raw.githubusercontent.com/inventare/django-image-uploader-widget/main/docs/_images/behaviour_inline.gif)\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2021 Eduardo Jos\u00e9 de Oliveira  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Simple Image Uploader Widget for Django-Admin",
    "version": "0.5.0",
    "project_urls": {
        "documentation": "https://inventare.github.io/django-image-uploader-widget/",
        "homepage": "https://github.com/inventare/django-image-uploader-widget"
    },
    "split_keywords": [
        "django",
        " admin",
        " widget",
        " image",
        " uploader"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2a9b71da6852e6df6a6d65f3fa13d3e075bb81509c8e89d44c39ffbda8a2898d",
                "md5": "3d2bae5a11135064d5191780a26039f9",
                "sha256": "f3aa0e2f2cae3aedee02157f7c9b919b9b66c3f60e4d7fcb695c0fe6be46f174"
            },
            "downloads": -1,
            "filename": "django_image_uploader_widget-0.5.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3d2bae5a11135064d5191780a26039f9",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 32044,
            "upload_time": "2024-04-03T11:48:54",
            "upload_time_iso_8601": "2024-04-03T11:48:54.604391Z",
            "url": "https://files.pythonhosted.org/packages/2a/9b/71da6852e6df6a6d65f3fa13d3e075bb81509c8e89d44c39ffbda8a2898d/django_image_uploader_widget-0.5.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7805bbf28cdb6d701d441e80dfcc40cbead1ca1287ead5e80741c5aca1c12e6b",
                "md5": "afeb222d9e3d39a48989b86c310c41af",
                "sha256": "9def1ea259eadce5a5a02d795ff27063f6922402b39c5cf5a756401c11e05afc"
            },
            "downloads": -1,
            "filename": "django-image-uploader-widget-0.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "afeb222d9e3d39a48989b86c310c41af",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 20985,
            "upload_time": "2024-04-03T11:48:56",
            "upload_time_iso_8601": "2024-04-03T11:48:56.270810Z",
            "url": "https://files.pythonhosted.org/packages/78/05/bbf28cdb6d701d441e80dfcc40cbead1ca1287ead5e80741c5aca1c12e6b/django-image-uploader-widget-0.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-03 11:48:56",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "inventare",
    "github_project": "django-image-uploader-widget",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "django-image-uploader-widget"
}
        
Elapsed time: 0.21929s