Name | django-image-assets JSON |
Version |
1.0.0
JSON |
| download |
home_page | None |
Summary | Django application for image assets management |
upload_time | 2024-07-17 10:43:35 |
maintainer | None |
docs_url | None |
author | None |
requires_python | None |
license | MIT |
keywords |
django
image
assets
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
django-image-assets
===================
Django application for image assets management.
[![Build Status](https://github.com/just-work/django-image-assets/workflows/build/badge.svg?branch=master&event=push)](https://github.com/just-work/django-image-assets/actions?query=event%3Apush+branch%3Amaster+workflow%3Abuild)
[![codecov](https://codecov.io/gh/just-work/django-image-assets/branch/master/graph/badge.svg)](https://codecov.io/gh/just-work/django-image-assets)
[![PyPI version](https://badge.fury.io/py/django-image-assets.svg)](https://badge.fury.io/py/django-image-assets)
Use case
--------
* There are several content types on a web site
* Each of them has a set of required or additional image assets
* Every asset of same asset type must satisfy custom constraints on dimensions,
format and file size.
* The most important thing: these constraints and required asset type sets are
updated often, along with web design evolves and more platforms are added.
Installation
------------
```shell script
pip install django-image-assets
```
Working example is in `testproject.testapp`.
1. Add `image_assets` application to installed apps in django settings:
```python
INSTALLED_APPS.append('image_assets')
```
2. Add generic relation to your content models:
```python
from django.contrib.contenttypes.fields import GenericRelation
from django.db import models
from image_assets.models import Asset
class Video(models.Model):
assets = GenericRelation(Asset, blank=True)
```
3. Setup inlines for assets
```python
from django.contrib import admin
from image_assets.admin import AssetsInline
from testproject.testapp import models
@admin.register(models.Video)
class VideoAdmin(admin.ModelAdmin):
inlines = (AssetsInline,)
```
Usage
-----
1. Create new asset type (i.e. "thumbnail")
2. Add `Video` to `allowed_for` set: now you can add a thumbnail to a video. Or
you may skip this asset.
3. Add `Article` to `required_for` set: now you will able to create or edit
an article with valid "thumbnail" asset only.
4. When an asset is deleted, it's file is owned by `DeletedAsset` object and may
be wiped later by manual or automatic cleanup.
Advanced
--------
If you need to alter model fields i.e. for `AssetType`, you may subclass
existing model and than change image_assets application settings.
1. Subclass `AssetType` model
```python
from django.db import models
from image_assets.models import AssetType
class MyAssetType(AssetType):
some_feature_flag = models.BooleanField(default=False)
```
2. Change a reference to an asset type model in settings:
```python
IMAGE_ASSETS_CONFIG = {
'ASSET_TYPE_MODEL': 'my_app.MyAssetType',
'ASSET_MODEL': 'image_assets.Asset',
'DELETED_ASSET_MODEL': 'image_assets.DeletedAsset'
}
```
3. `image_assets.AssetType` will be declared as abstract and `MyAssetType`
will be returned as result of `image_assets.models.get_asset_type_model()`
Raw data
{
"_id": null,
"home_page": null,
"name": "django-image-assets",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "django, image, assets",
"author": null,
"author_email": "Sergey Tikhonov <zimbler@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/3d/04/a1e8f5f8da0e0903dbf272ec4d2af36cb20385bd8b520da45e9d610762c8/django_image_assets-1.0.0.tar.gz",
"platform": null,
"description": "django-image-assets\n===================\n\nDjango application for image assets management.\n\n[![Build Status](https://github.com/just-work/django-image-assets/workflows/build/badge.svg?branch=master&event=push)](https://github.com/just-work/django-image-assets/actions?query=event%3Apush+branch%3Amaster+workflow%3Abuild)\n[![codecov](https://codecov.io/gh/just-work/django-image-assets/branch/master/graph/badge.svg)](https://codecov.io/gh/just-work/django-image-assets)\n[![PyPI version](https://badge.fury.io/py/django-image-assets.svg)](https://badge.fury.io/py/django-image-assets)\n\nUse case\n--------\n\n* There are several content types on a web site\n* Each of them has a set of required or additional image assets\n* Every asset of same asset type must satisfy custom constraints on dimensions, \n format and file size.\n* The most important thing: these constraints and required asset type sets are\n updated often, along with web design evolves and more platforms are added.\n\nInstallation\n------------\n\n```shell script\npip install django-image-assets\n```\n\nWorking example is in `testproject.testapp`.\n\n1. Add `image_assets` application to installed apps in django settings:\n ```python\n INSTALLED_APPS.append('image_assets')\n ```\n2. Add generic relation to your content models:\n ```python\n from django.contrib.contenttypes.fields import GenericRelation\n from django.db import models\n \n from image_assets.models import Asset\n \n \n class Video(models.Model):\n assets = GenericRelation(Asset, blank=True)\n ```\n \n3. Setup inlines for assets\n ```python\n from django.contrib import admin\n \n from image_assets.admin import AssetsInline\n from testproject.testapp import models\n \n \n @admin.register(models.Video)\n class VideoAdmin(admin.ModelAdmin):\n inlines = (AssetsInline,)\n ```\n\nUsage\n-----\n\n1. Create new asset type (i.e. \"thumbnail\")\n2. Add `Video` to `allowed_for` set: now you can add a thumbnail to a video. Or \n you may skip this asset.\n3. Add `Article` to `required_for` set: now you will able to create or edit\n an article with valid \"thumbnail\" asset only.\n4. When an asset is deleted, it's file is owned by `DeletedAsset` object and may \n be wiped later by manual or automatic cleanup.\n\nAdvanced\n--------\n\nIf you need to alter model fields i.e. for `AssetType`, you may subclass\nexisting model and than change image_assets application settings.\n\n1. Subclass `AssetType` model\n ```python\n from django.db import models\n from image_assets.models import AssetType\n \n \n class MyAssetType(AssetType):\n some_feature_flag = models.BooleanField(default=False)\n ```\n2. Change a reference to an asset type model in settings:\n ```python\n IMAGE_ASSETS_CONFIG = {\n 'ASSET_TYPE_MODEL': 'my_app.MyAssetType',\n 'ASSET_MODEL': 'image_assets.Asset',\n 'DELETED_ASSET_MODEL': 'image_assets.DeletedAsset'\n }\n ```\n3. `image_assets.AssetType` will be declared as abstract and `MyAssetType`\n will be returned as result of `image_assets.models.get_asset_type_model()`\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Django application for image assets management",
"version": "1.0.0",
"project_urls": {
"documentation": "https://github.com/just-work/django-image-assets/blob/master/README.md",
"homepage": "https://github.com/just-work/django-image-assets",
"issues": "https://github.com/just-work/django-image-assets/issues",
"repository": "https://github.com/just-work/django-image-assets.git"
},
"split_keywords": [
"django",
" image",
" assets"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7d518ec692e7984d49b5a5c7d98cbb43b4a21ccdfb0d3ce2a0122ef075cbafc3",
"md5": "25d012785c33af5228b38b20f767e703",
"sha256": "4ce6b97354f9becc834469e9d2f35894c07c9feae8e09b711d0205f7699a7b1e"
},
"downloads": -1,
"filename": "django_image_assets-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "25d012785c33af5228b38b20f767e703",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 17246,
"upload_time": "2024-07-17T10:43:33",
"upload_time_iso_8601": "2024-07-17T10:43:33.695662Z",
"url": "https://files.pythonhosted.org/packages/7d/51/8ec692e7984d49b5a5c7d98cbb43b4a21ccdfb0d3ce2a0122ef075cbafc3/django_image_assets-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3d04a1e8f5f8da0e0903dbf272ec4d2af36cb20385bd8b520da45e9d610762c8",
"md5": "95d309de5c340112e847488cf6720d5a",
"sha256": "2cd908cb4656bc17e4f5a1be2a3a47903700636733afc778d8e9f8facf65cb69"
},
"downloads": -1,
"filename": "django_image_assets-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "95d309de5c340112e847488cf6720d5a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 11044,
"upload_time": "2024-07-17T10:43:35",
"upload_time_iso_8601": "2024-07-17T10:43:35.686724Z",
"url": "https://files.pythonhosted.org/packages/3d/04/a1e8f5f8da0e0903dbf272ec4d2af36cb20385bd8b520da45e9d610762c8/django_image_assets-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-17 10:43:35",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "just-work",
"github_project": "django-image-assets",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"tox": true,
"lcname": "django-image-assets"
}