Skip to main content

A form field to handle validation of image + svg

Project description

https://badge.fury.io/py/django-svg-image-form-field.svg

A form field to handle validation of image + svg

Quickstart

Install Django SVG Image Field:

pip install django-svg-image-form-field

Models:

from django.db import models


class Article(models.Model):
    title = models.CharField(max_length=100)
    image = models.ImageField(upload_to='images/articles')
    text = models.TextField()

Forms:

from django import forms

from .models import Article
from django_svg_image_form_field import SvgAndImageFormField


class ArticleForm(forms.ModelForm):
    class Meta:
        model = Article
        exclude = []
        field_classes = {
            'image': SvgAndImageFormField,
        }

Example usage:

from django.contrib import admin

from .forms import ArticleForm
from .models import Article


@admin.register(Article)
class SectionAdmin(admin.ModelAdmin):
    list_display = 'id', 'title'
    search_fields = 'title',
    form = ArticleForm

Credits

Tools used in rendering this package:

History

0.1.0 (2021-04-15)

  • First release on PyPI.

1.0.0 (2021-04-15)

  • Stable version (tested on demo project).

1.0.1 (2021-06-14)

  • Fix when the input is the temporary file path instead the BytesIO (thanks fbuccioni).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-svg-image-form-field-1.0.1.tar.gz (5.1 kB view hashes)

Uploaded Source

Built Distribution

django_svg_image_form_field-1.0.1-py2.py3-none-any.whl (5.0 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page