Ticket #8210: 8210-2.diff

File 8210-2.diff, 8.2 KB (added by Matt McClanahan, 16 years ago)
  • django/db/models/fields/__init__.py

     
    866866        defaults.update(kwargs)
    867867        return super(URLField, self).formfield(**defaults)
    868868
    869 class USStateField(Field):
    870     def get_internal_type(self):
    871         return "USStateField"
    872 
    873     def formfield(self, **kwargs):
    874         from django.contrib.localflavor.us.forms import USStateSelect
    875         defaults = {'widget': USStateSelect}
    876         defaults.update(kwargs)
    877         return super(USStateField, self).formfield(**defaults)
    878 
    879869class XMLField(TextField):
    880870    def __init__(self, verbose_name=None, name=None, schema_path=None, **kwargs):
    881871        self.schema_path = schema_path
  • django/db/backends/postgresql/creation.py

     
    2828        'SmallIntegerField': 'smallint',
    2929        'TextField':         'text',
    3030        'TimeField':         'time',
    31         'USStateField':      'varchar(2)',
    3231    }
    3332
    3433    def sql_table_creation_suffix(self):
  • django/db/backends/sqlite3/creation.py

     
    2929        'SmallIntegerField':            'smallint',
    3030        'TextField':                    'text',
    3131        'TimeField':                    'time',
    32         'USStateField':                 'varchar(2)',
    3332    }
    3433   
    3534    def sql_for_pending_references(self, model, style, pending_references):
  • django/db/backends/mysql/creation.py

     
    2828        'SmallIntegerField': 'smallint',
    2929        'TextField':         'longtext',
    3030        'TimeField':         'time',
    31         'USStateField':      'varchar(2)',
    3231    }
    3332
    3433    def sql_table_creation_suffix(self):
  • django/db/backends/oracle/creation.py

     
    3838        'TextField':                    'NCLOB',
    3939        'TimeField':                    'TIMESTAMP',
    4040        'URLField':                     'VARCHAR2(%(max_length)s)',
    41         'USStateField':                 'CHAR(2)',
    4241    }
    4342
    4443    remember = {}
  • django/contrib/gis/utils/layermapping.py

     
    118118    OFTDate, OFTDateTime, OFTInteger, OFTReal, OFTString, OFTTime
    119119from django.contrib.gis.models import GeometryColumns, SpatialRefSys
    120120from django.db import models, transaction
     121from django.contrib.localflavor.us.models import USStateField
    121122
    122123# LayerMapping exceptions.
    123124class LayerMapError(Exception): pass
     
    150151        models.SlugField : OFTString,
    151152        models.TextField : OFTString,
    152153        models.URLField : OFTString,
    153         models.USStateField : OFTString,
     154        USStateField : OFTString,
    154155        models.XMLField : OFTString,
    155156        models.SmallIntegerField : (OFTInteger, OFTReal, OFTString),
    156157        models.PositiveSmallIntegerField : (OFTInteger, OFTReal, OFTString),
  • django/contrib/gis/tests/relatedapp/models.py

     
    11from django.contrib.gis.db import models
     2from django.contrib.localflavor.us.models import USStateField
    23
    34class Location(models.Model):
    45    name = models.CharField(max_length=50)
     
    78
    89class City(models.Model):
    910    name = models.CharField(max_length=50)
    10     state = models.USStateField()
     11    state = USStateField()
    1112    location = models.ForeignKey(Location)
    1213    objects = models.GeoManager()
  • tests/regressiontests/serializers_regress/models.py

     
    88from django.db import models
    99from django.contrib.contenttypes import generic
    1010from django.contrib.contenttypes.models import ContentType
     11from django.contrib.localflavor.us.models import USStateField
    1112
    1213# The following classes are for testing basic data
    1314# marshalling, including NULL values.
     
    7374    data = models.TimeField(null=True)
    7475
    7576class USStateData(models.Model):
    76     data = models.USStateField(null=True)
     77    data = USStateField(null=True)
    7778
    7879class XMLData(models.Model):
    7980    data = models.XMLField(null=True)
     
    209210#    data = models.TimeField(primary_key=True)
    210211
    211212class USStatePKData(models.Model):
    212     data = models.USStateField(primary_key=True)
     213    data = USStateField(primary_key=True)
    213214
    214215# class XMLPKData(models.Model):
    215216#     data = models.XMLField(primary_key=True)
  • docs/topics/db/models.txt

     
    617617
    618618For example, this model has a few custom methods::
    619619
     620    from django.contrib.localflavor.us.models import USStateField
    620621    class Person(models.Model):
    621622        first_name = models.CharField(max_length=50)
    622623        last_name = models.CharField(max_length=50)
    623624        birth_date = models.DateField()
    624625        address = models.CharField(max_length=100)
    625626        city = models.CharField(max_length=50)
    626         state = models.USStateField() # Yes, this is America-centric...
     627        state = USStateField() # Yes, this is America-centric...
    627628
    628629        def baby_boomer_status(self):
    629630            "Returns the person's baby-boomer status."
  • docs/topics/forms/modelforms.txt

     
    7373    ``TimeField``                    ``TimeField``
    7474    ``URLField``                     ``URLField`` with ``verify_exists`` set
    7575                                     to the model field's ``verify_exists``
    76     ``USStateField``                 ``CharField`` with
    77                                      ``widget=USStateSelect``
    78                                      (``USStateSelect`` is from
    79                                      ``django.contrib.localflavor.us``)
    8076    ``XMLField``                     ``CharField`` with ``widget=Textarea``
    8177    ===============================  ========================================
    8278
  • docs/ref/contrib/localflavor.txt

     
    649649
    650650    A form ``Select`` widget that uses a list of U.S. states/territories as its
    651651    choices.
     652
     653.. class:: us.models.USStateField
     654
     655    A model field that forms represent as a ``forms.USStateField`` field and
     656    stores the two-letter U.S. state abbreviation in the database.
  • docs/ref/models/fields.txt

     
    705705:attr:`~CharField.max_length`argument. If you don't specify
    706706:attr:`~CharField.max_length`, a default of 200 is used.
    707707
    708 ``USStateField``
    709 ----------------
    710 
    711 .. class:: USStateField([**options])
    712 
    713 A two-letter U.S. state abbreviation. The admin represents this as an ``<input
    714 type="text">`` (a single-line input).
    715 
    716708``XMLField``
    717709------------
    718710
Back to Top