A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://django-mysql.readthedocs.io/en/latest/model_fields/fixedchar_field.html below:

FixedCharField - django-mysql 4.17.0 documentation

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.

Docs: MySQL / MariaDB.

class django_mysql.models.FixedCharField(*args, max_length: int, **kwargs)

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