Ticket #8210: 8210-1.diff

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

     
    842842        defaults.update(kwargs)
    843843        return super(URLField, self).formfield(**defaults)
    844844
    845 class USStateField(Field):
    846     def get_internal_type(self):
    847         return "USStateField"
    848 
    849     def formfield(self, **kwargs):
    850         from django.contrib.localflavor.us.forms import USStateSelect
    851         defaults = {'widget': USStateSelect}
    852         defaults.update(kwargs)
    853         return super(USStateField, self).formfield(**defaults)
    854 
    855845class XMLField(TextField):
    856846    def __init__(self, verbose_name=None, name=None, schema_path=None, **kwargs):
    857847        self.schema_path = schema_path
  • 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()
  • django/contrib/localflavor/us/models.py

     
     1from django.db.models.fields import Field
     2
     3class USStateField(Field):
     4    def get_internal_type(self):
     5        return "USStateField"
     6
     7    def formfield(self, **kwargs):
     8        from django.contrib.localflavor.us.forms import USStateSelect
     9        defaults = {'widget': USStateSelect}
     10        defaults.update(kwargs)
     11        return super(USStateField, self).formfield(**defaults)
  • 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/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