Skip to content
Better string field for Django.
Python
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
stringfield going stable
tests going stable
.gitignore 1
LICENSE 1
MANIFEST.in 1
README.rst 500
setup.py going stable

README.rst

django-stringfield

A field intended for strings that typically has a length less than 500 characters. django-stringfield tries to not to enforce length on database level if possible but different databases have different limitations. Currently implemented as:

PostgreSQL
character varying
MySQL
VARCHAR (65528) [1]
Oracle
VARCHAR2 (4000)
SQLite & Other backends
TEXT

Installation

pip install django-stringfield

Usage

You use this just like the normal django.db.models.CharField except that the key word argument max_length works a little differently:

  • It is optional and defaults to 500
  • It only enforces max length on the default formfield not on the database.

Example:

# models.py
from stringfield import StringField

class MyModel(models.Model):
    name = StringField()
[1]MySQL >= 5.0.3 should be able to handle a maximum length of 65535 but that does not work in my empirical testing using mysql 5.1.41 where 65528 is the maximum considering NULL and NOT NULL.
Something went wrong with that request. Please try again.