Toggle table of contents sidebar
FixedCharField¶Django’s CharField
uses the VARCHAR
data type, which uses variable storage space depending on string length. This normally saves storage space, but for columns with a fixed length, it adds a small overhead.
The alternative CHAR
data type avoids that overhead, but it has the surprising behaviour of removing trailing space characters, and consequently ignoring them in comparisons. FixedCharField
provides a Django field for using CHAR
. This can help you interface with databases created by other systems, but it’s not recommended for general use, due to the trialing space behaviour.
A subclass of Django’s Charfield
that uses the CHAR
data type. max_length
is as with CharField
, but must be within the range 0-255.
For example:
from django_mysql.models import FixedCharField class Address(Model): zip_code = FixedCharField(length=5)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4