from django.db import models
from django.utils.translation import ugettext_lazy as _
"A basically unlimited-length CharField."
description = _("Unlimited-length string")
def __init__(self, *args, **kwargs):
kwargs['max_length'] = int(1e9) # Satisfy management validation.
super(models.CharField, self).__init__(*args, **kwargs)
# Don't add max-length validator like CharField does.
# This has no function, since this value is used as a lookup in
# db_type(). Put something that isn't known by django so it
# raises an error if it is ever used.
def db_type(self, connection):
# *** This is probably only compatible with Postgres.
# 'varchar' with no max length is equivalent to 'text' in Postgres,
# but put 'varchar' so we can tell LongCharFields from TextFields
# when we're looking at the db.
def formfield(self, **kwargs):
# Don't pass max_length to form field like CharField does.
return super(models.CharField, self).formfield(**kwargs)