Add UTF-8 Validation to a Django FileField
Project description
Sometimes you want to only allow the uploading of UTF-8 text files. This library extends the Django FileField by checking if the content of a file is UTF-8. If not, it generates an error.
Requirements
Django >= 1.8
Installation
pip install django-utf8field
Usage
Add the app to your settings:
INSTALLED_APPS = ( ... 'utf8field', ...
Create a model like you would do normally, but instead of using FileField you use UTF8FileField:
from django.db import models from utf8field.fields import UTF8FileField class YourModel(models.Model): title = models.CharField(max_length=255) created_on = models.DateTimeField(auto_add_on=True) text = models.UTF8FileField()
You also have the option to provide the option max_content_length to limit the number of characters in the file. If the content is longer an error will be displayed.
text = models.UTF8FileField(max_content_length=1000)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
django-utf8field-0.1.0.tar.gz
(2.3 kB
view hashes)
Built Distribution
Close
Hashes for django_utf8field-0.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 468a1a0421e78306a745c0f46dc3f3c569a143eaf87e3d53e0be80ecc43d0659 |
|
MD5 | e3a76faf9a4cec1e62491b1833a8d1d8 |
|
BLAKE2b-256 | e8182cf6cecf01577ec81129314a4fd33c76ed9ff7ff4a1beb92015573e7e7d2 |