Skip to main content

Better string field for Django.

Project description

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:

character varying
VARCHAR (65528) [1]
VARCHAR2 (4000)
SQLite & Other backends


pip install django-stringfield


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.


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.

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-stringfield-0.3.0.tar.gz (4.1 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page