Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Stef Bastiaansen committed Oct 10, 2017
1 parent b30aa7d commit 749a3ac
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Django UTF-8 Field
:alt: Coverage

This package was created because at my work, `Language and Translation Technology Team`_ at the University of Ghent, we often create demos on the web that allow the user to input and process text or files. These texts are then processed by other scripts that expect clean UTF-8-texts.
This library extends the Django FileField, CharField and TextField by checking if the content of a submitted file or text is clean UTF-8. If not, it generates an error. Extra checks are executed for four byte long characters and NULL characters.
This library extends the Django FileField, CharField and TextField by checking if the content of a submitted file or text is clean. If not, it generates an error. Checks are executed for four byte long characters and NULL characters.


Requirements
Expand Down Expand Up @@ -54,32 +54,33 @@ Create a model like you would do normally, but instead of using FileField you us
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.
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. If you want to enable `four_byte_detection` set the parameter to True.


::

text = models.UTF8FileField(max_content_length=1000)
text = models.UTF8FileField(max_content_length=1000, four_byte_detection=True)



CharField
^^^^^^^^^
Create a model like you would do normally, but instead of using CharField you use UTF8CharField:
Create a model like you would do normally, but instead of using CharField you use UTF8CharField. If you want to enable `four_byte_detection` set the parameter to True.

::

from django.db import models
from utf8field.fields import UTF8CharField

class YourModel(models.Model):
title = models.CharField(max_length=255)
title = models.CharField(max_length=255, four_byte_detection=True)
created_on = models.DateTimeField(auto_add_on=True)
text = models.UTF8CharField(max_length=1000)


TextField
^^^^^^^^^
Create a model like you would do normally, but instead of using TextField you use UTF8TextField:
Create a model like you would do normally, but instead of using TextField you use UTF8TextField. If you want to enable `four_byte_detection` set the parameter to True.

::

Expand All @@ -89,7 +90,7 @@ Create a model like you would do normally, but instead of using TextField you us
class YourModel(models.Model):
title = models.CharField(max_length=255)
created_on = models.DateTimeField(auto_add_on=True)
text = models.UTF8TextField()
text = models.UTF8TextField(four_byte_detection=True)



Expand Down

0 comments on commit 749a3ac

Please sign in to comment.