Ticket #8210: 8210-2.diff
File 8210-2.diff, 8.2 KB (added by , 16 years ago) |
---|
-
django/db/models/fields/__init__.py
866 866 defaults.update(kwargs) 867 867 return super(URLField, self).formfield(**defaults) 868 868 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 USStateSelect875 defaults = {'widget': USStateSelect}876 defaults.update(kwargs)877 return super(USStateField, self).formfield(**defaults)878 879 869 class XMLField(TextField): 880 870 def __init__(self, verbose_name=None, name=None, schema_path=None, **kwargs): 881 871 self.schema_path = schema_path -
django/db/backends/postgresql/creation.py
28 28 'SmallIntegerField': 'smallint', 29 29 'TextField': 'text', 30 30 'TimeField': 'time', 31 'USStateField': 'varchar(2)',32 31 } 33 32 34 33 def sql_table_creation_suffix(self): -
django/db/backends/sqlite3/creation.py
29 29 'SmallIntegerField': 'smallint', 30 30 'TextField': 'text', 31 31 'TimeField': 'time', 32 'USStateField': 'varchar(2)',33 32 } 34 33 35 34 def sql_for_pending_references(self, model, style, pending_references): -
django/db/backends/mysql/creation.py
28 28 'SmallIntegerField': 'smallint', 29 29 'TextField': 'longtext', 30 30 'TimeField': 'time', 31 'USStateField': 'varchar(2)',32 31 } 33 32 34 33 def sql_table_creation_suffix(self): -
django/db/backends/oracle/creation.py
38 38 'TextField': 'NCLOB', 39 39 'TimeField': 'TIMESTAMP', 40 40 'URLField': 'VARCHAR2(%(max_length)s)', 41 'USStateField': 'CHAR(2)',42 41 } 43 42 44 43 remember = {} -
django/contrib/gis/utils/layermapping.py
118 118 OFTDate, OFTDateTime, OFTInteger, OFTReal, OFTString, OFTTime 119 119 from django.contrib.gis.models import GeometryColumns, SpatialRefSys 120 120 from django.db import models, transaction 121 from django.contrib.localflavor.us.models import USStateField 121 122 122 123 # LayerMapping exceptions. 123 124 class LayerMapError(Exception): pass … … 150 151 models.SlugField : OFTString, 151 152 models.TextField : OFTString, 152 153 models.URLField : OFTString, 153 models.USStateField : OFTString,154 USStateField : OFTString, 154 155 models.XMLField : OFTString, 155 156 models.SmallIntegerField : (OFTInteger, OFTReal, OFTString), 156 157 models.PositiveSmallIntegerField : (OFTInteger, OFTReal, OFTString), -
django/contrib/gis/tests/relatedapp/models.py
1 1 from django.contrib.gis.db import models 2 from django.contrib.localflavor.us.models import USStateField 2 3 3 4 class Location(models.Model): 4 5 name = models.CharField(max_length=50) … … 7 8 8 9 class City(models.Model): 9 10 name = models.CharField(max_length=50) 10 state = models.USStateField()11 state = USStateField() 11 12 location = models.ForeignKey(Location) 12 13 objects = models.GeoManager() -
tests/regressiontests/serializers_regress/models.py
8 8 from django.db import models 9 9 from django.contrib.contenttypes import generic 10 10 from django.contrib.contenttypes.models import ContentType 11 from django.contrib.localflavor.us.models import USStateField 11 12 12 13 # The following classes are for testing basic data 13 14 # marshalling, including NULL values. … … 73 74 data = models.TimeField(null=True) 74 75 75 76 class USStateData(models.Model): 76 data = models.USStateField(null=True)77 data = USStateField(null=True) 77 78 78 79 class XMLData(models.Model): 79 80 data = models.XMLField(null=True) … … 209 210 # data = models.TimeField(primary_key=True) 210 211 211 212 class USStatePKData(models.Model): 212 data = models.USStateField(primary_key=True)213 data = USStateField(primary_key=True) 213 214 214 215 # class XMLPKData(models.Model): 215 216 # data = models.XMLField(primary_key=True) -
docs/topics/db/models.txt
617 617 618 618 For example, this model has a few custom methods:: 619 619 620 from django.contrib.localflavor.us.models import USStateField 620 621 class Person(models.Model): 621 622 first_name = models.CharField(max_length=50) 622 623 last_name = models.CharField(max_length=50) 623 624 birth_date = models.DateField() 624 625 address = models.CharField(max_length=100) 625 626 city = models.CharField(max_length=50) 626 state = models.USStateField() # Yes, this is America-centric...627 state = USStateField() # Yes, this is America-centric... 627 628 628 629 def baby_boomer_status(self): 629 630 "Returns the person's baby-boomer status." -
docs/topics/forms/modelforms.txt
73 73 ``TimeField`` ``TimeField`` 74 74 ``URLField`` ``URLField`` with ``verify_exists`` set 75 75 to the model field's ``verify_exists`` 76 ``USStateField`` ``CharField`` with77 ``widget=USStateSelect``78 (``USStateSelect`` is from79 ``django.contrib.localflavor.us``)80 76 ``XMLField`` ``CharField`` with ``widget=Textarea`` 81 77 =============================== ======================================== 82 78 -
docs/ref/contrib/localflavor.txt
649 649 650 650 A form ``Select`` widget that uses a list of U.S. states/territories as its 651 651 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
705 705 :attr:`~CharField.max_length`argument. If you don't specify 706 706 :attr:`~CharField.max_length`, a default of 200 is used. 707 707 708 ``USStateField``709 ----------------710 711 .. class:: USStateField([**options])712 713 A two-letter U.S. state abbreviation. The admin represents this as an ``<input714 type="text">`` (a single-line input).715 716 708 ``XMLField`` 717 709 ------------ 718 710