Django

Code

Show
Ignore:
Timestamp:
08/06/07 11:50:17 (1 year ago)
Author:
danderson
Message:

schema-evolution: update from HEAD (v5821)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/schema-evolution/tests/regressiontests/bug639/models.py

    r5734 r5822  
    33 
    44class Photo(models.Model): 
    5     title = models.CharField(maxlength=30) 
     5    title = models.CharField(max_length=30) 
    66    image = models.FileField(upload_to=tempfile.gettempdir()) 
    77     
  • django/branches/schema-evolution/tests/regressiontests/datatypes/models.py

    r5734 r5822  
    88 
    99class Donut(models.Model): 
    10     name = models.CharField(maxlength=100) 
     10    name = models.CharField(max_length=100) 
    1111    is_frosted = models.BooleanField(default=False) 
    1212    has_sprinkles = models.NullBooleanField() 
  • django/branches/schema-evolution/tests/regressiontests/fixtures_regress/models.py

    r5734 r5822  
    33 
    44class Animal(models.Model): 
    5     name = models.CharField(maxlength=150) 
    6     latin_name = models.CharField(maxlength=150) 
     5    name = models.CharField(max_length=150) 
     6    latin_name = models.CharField(max_length=150) 
    77 
    88    def __unicode__(self): 
     
    1010 
    1111class Plant(models.Model): 
    12     name = models.CharField(maxlength=150) 
     12    name = models.CharField(max_length=150) 
    1313 
    1414    class Meta: 
     
    1717 
    1818class Stuff(models.Model): 
    19     name = models.CharField(maxlength=20, null=True) 
     19    name = models.CharField(max_length=20, null=True) 
    2020    owner = models.ForeignKey(User, null=True) 
    2121     
  • django/branches/schema-evolution/tests/regressiontests/forms/tests.py

    r5788 r5822  
    174174# FileInput Widget ############################################################ 
    175175 
     176FileInput widgets don't ever show the value, because the old value is of no use 
     177if you are updating the form or if the provided file generated an error. 
    176178>>> w = FileInput() 
    177179>>> w.render('email', '') 
     
    180182u'<input type="file" name="email" />' 
    181183>>> w.render('email', 'test@example.com') 
    182 u'<input type="file" name="email" value="test@example.com" />' 
     184u'<input type="file" name="email" />' 
    183185>>> w.render('email', 'some "quoted" & ampersanded value') 
    184 u'<input type="file" name="email" value="some &quot;quoted&quot; &amp; ampersanded value" />' 
     186u'<input type="file" name="email" />' 
    185187>>> w.render('email', 'test@example.com', attrs={'class': 'fun'}) 
    186 u'<input type="file" name="email" value="test@example.com" class="fun" />' 
     188u'<input type="file" name="email" class="fun" />' 
    187189 
    188190You can also pass 'attrs' to the constructor: 
     
    191193u'<input type="file" class="fun" name="email" />' 
    192194>>> w.render('email', 'foo@example.com') 
    193 u'<input type="file" class="fun" value="foo@example.com" name="email" />' 
     195u'<input type="file" class="fun" name="email" />' 
    194196 
    195197>>> w.render('email', 'ŠĐĆŽćžšđ', attrs={'class': 'fun'}) 
    196 u'<input type="file" class="fun" value="\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111" name="email" />' 
     198u'<input type="file" class="fun" name="email" />' 
    197199 
    198200# Textarea Widget ############################################################# 
     
    15321534... 
    15331535ValidationError: [u'Ensure this value has at most 15 characters (it has 20).'] 
     1536 
     1537# FileField ################################################################## 
     1538 
     1539>>> f = FileField() 
     1540>>> f.clean('') 
     1541Traceback (most recent call last): 
     1542... 
     1543ValidationError: [u'This field is required.'] 
     1544 
     1545>>> f.clean(None) 
     1546Traceback (most recent call last): 
     1547... 
     1548ValidationError: [u'This field is required.'] 
     1549 
     1550>>> f.clean({}) 
     1551Traceback (most recent call last): 
     1552... 
     1553ValidationError: [u'No file was submitted.'] 
     1554 
     1555>>> f.clean('some content that is not a file') 
     1556Traceback (most recent call last): 
     1557... 
     1558ValidationError: [u'No file was submitted. Check the encoding type on the form.'] 
     1559 
     1560>>> f.clean({'filename': 'name', 'content':None}) 
     1561Traceback (most recent call last): 
     1562... 
     1563ValidationError: [u'The submitted file is empty.'] 
     1564 
     1565>>> f.clean({'filename': 'name', 'content':''}) 
     1566Traceback (most recent call last): 
     1567... 
     1568ValidationError: [u'The submitted file is empty.'] 
     1569 
     1570>>> type(f.clean({'filename': 'name', 'content':'Some File Content'})) 
     1571<class 'django.newforms.fields.UploadedFile'> 
    15341572 
    15351573# URLField ################################################################## 
     
    25742612>>> class MyForm(Form): 
    25752613...     def __init__(self, data=None, auto_id=False, field_list=[]): 
    2576 ...         Form.__init__(self, data, auto_id
     2614...         Form.__init__(self, data, auto_id=auto_id
    25772615...         for field in field_list: 
    25782616...             self.fields[field[0]] = field[1] 
     
    25922630...     default_field_2 = CharField() 
    25932631...     def __init__(self, data=None, auto_id=False, field_list=[]): 
    2594 ...         Form.__init__(self, data, auto_id
     2632...         Form.__init__(self, data, auto_id=auto_id
    25952633...         for field in field_list: 
    25962634...             self.fields[field[0]] = field[1] 
     
    32473285</select> 
    32483286 
     3287# Forms with FileFields ################################################ 
     3288 
     3289FileFields are a special case because they take their data from the request.FILES, 
     3290not request.POST.  
     3291 
     3292>>> class FileForm(Form): 
     3293...     file1 = FileField() 
     3294>>> f = FileForm(auto_id=False) 
     3295>>> print f 
     3296<tr><th>File1:</th><td><input type="file" name="file1" /></td></tr> 
     3297 
     3298>>> f = FileForm(data={}, files={}, auto_id=False) 
     3299>>> print f 
     3300<tr><th>File1:</th><td><ul class="errorlist"><li>This field is required.</li></ul><input type="file" name="file1" /></td></tr> 
     3301 
     3302>>> f = FileForm(data={}, files={'file1': {'filename': 'name', 'content':''}}, auto_id=False) 
     3303>>> print f 
     3304<tr><th>File1:</th><td><ul class="errorlist"><li>The submitted file is empty.</li></ul><input type="file" name="file1" /></td></tr> 
     3305 
     3306>>> f = FileForm(data={}, files={'file1': 'something that is not a file'}, auto_id=False) 
     3307>>> print f 
     3308<tr><th>File1:</th><td><ul class="errorlist"><li>No file was submitted. Check the encoding type on the form.</li></ul><input type="file" name="file1" /></td></tr> 
     3309 
     3310>>> f = FileForm(data={}, files={'file1': {'filename': 'name', 'content':'some content'}}, auto_id=False) 
     3311>>> print f 
     3312<tr><th>File1:</th><td><input type="file" name="file1" /></td></tr> 
     3313>>> f.is_valid() 
     3314True 
     3315 
    32493316# Basic form processing in a view ############################################# 
    32503317 
  • django/branches/schema-evolution/tests/regressiontests/initial_sql_regress/models.py

    r3937 r5822  
    66 
    77class Simple(models.Model): 
    8     name = models.CharField(maxlength = 50) 
     8    name = models.CharField(max_length = 50) 
    99 
    1010__test__ = {'API_TESTS':""} 
  • django/branches/schema-evolution/tests/regressiontests/invalid_admin_options/models.py

    r5734 r5822  
    1313#class BadAdminOption(models.Model): 
    1414#    "Test nonexistent admin option" 
    15 #    name = models.CharField(maxlength=30) 
     15#    name = models.CharField(max_length=30) 
    1616#     
    1717#    class Admin: 
     
    2323class ListDisplayBadOne(models.Model): 
    2424    "Test list_display, list_display must be a list or tuple" 
    25     first_name = models.CharField(maxlength=30) 
     25    first_name = models.CharField(max_length=30) 
    2626 
    2727    class Admin: 
     
    3333class ListDisplayBadTwo(models.Model): 
    3434    "Test list_display, list_display items must be attributes, methods or properties." 
    35     first_name = models.CharField(maxlength=30) 
     35    first_name = models.CharField(max_length=30) 
    3636 
    3737    class Admin: 
     
    4242class ListDisplayBadThree(models.Model): 
    4343    "Test list_display, list_display items can not be a ManyToManyField." 
    44     first_name = models.CharField(maxlength=30) 
     44    first_name = models.CharField(max_length=30) 
    4545    nick_names = models.ManyToManyField('ListDisplayGood') 
    4646 
     
    5353class ListDisplayGood(models.Model): 
    5454    "Test list_display, Admin list_display can be a attribute, method or property." 
    55     first_name = models.CharField(maxlength=30) 
     55    first_name = models.CharField(max_length=30) 
    5656     
    5757    def _last_name(self): 
     
    6767class ListDisplayLinksBadOne(models.Model): 
    6868    "Test list_display_links, item must be included in list_display." 
    69     first_name = models.CharField(maxlength=30) 
    70     last_name = models.CharField(maxlength=30) 
     69    first_name = models.CharField(max_length=30) 
     70    last_name = models.CharField(max_length=30) 
    7171     
    7272    class Admin: 
     
    7979class ListDisplayLinksBadTwo(models.Model): 
    8080    "Test list_display_links, must be a list or tuple." 
    81     first_name = models.CharField(maxlength=30) 
    82     last_name = models.CharField(maxlength=30) 
     81    first_name = models.CharField(max_length=30) 
     82    last_name = models.CharField(max_length=30) 
    8383     
    8484    class Admin: 
     
    9393#class ListDisplayLinksBadThree(models.Model): 
    9494#    "Test list_display_links, must define list_display to use list_display_links." 
    95 #    first_name = models.CharField(maxlength=30) 
    96 #    last_name = models.CharField(maxlength=30) 
     95#    first_name = models.CharField(max_length=30) 
     96#    last_name = models.CharField(max_length=30) 
    9797#     
    9898#    class Admin: 
     
    104104class ListDisplayLinksGood(models.Model): 
    105105    "Test list_display_links, Admin list_display_list can be a attribute, method or property." 
    106     first_name = models.CharField(maxlength=30) 
     106    first_name = models.CharField(max_length=30) 
    107107     
    108108    def _last_name(self): 
     
    119119class ListFilterBadOne(models.Model): 
    120120    "Test list_filter, must be a list or tuple." 
    121     first_name = models.CharField(maxlength=30) 
     121    first_name = models.CharField(max_length=30) 
    122122     
    123123    class Admin: 
     
    129129class ListFilterBadTwo(models.Model): 
    130130    "Test list_filter, must be a field not a property or method." 
    131     first_name = models.CharField(maxlength=30) 
     131    first_name = models.CharField(max_length=30) 
    132132     
    133133    def _last_name(self): 
     
    147147class DateHierarchyBadOne(models.Model): 
    148148    "Test date_hierarchy, must be a date or datetime field." 
    149     first_name = models.CharField(maxlength=30) 
     149    first_name = models.CharField(max_length=30) 
    150150    birth_day = models.DateField() 
    151151     
     
    159159class DateHierarchyBadTwo(models.Model): 
    160160    "Test date_hieracrhy, must be a field." 
    161     first_name = models.CharField(maxlength=30) 
     161    first_name = models.CharField(max_length=30) 
    162162    birth_day = models.DateField() 
    163163     
     
    170170class DateHierarchyGood(models.Model): 
    171171    "Test date_hieracrhy, must be a field." 
    172     first_name = models.CharField(maxlength=30) 
     172    first_name = models.CharField(max_length=30) 
    173173    birth_day = models.DateField() 
    174174     
     
    178178class SearchFieldsBadOne(models.Model): 
    179179    "Test search_fields, must be a list or tuple." 
    180     first_name = models.CharField(maxlength=30) 
     180    first_name = models.CharField(max_length=30) 
    181181     
    182182    class Admin: 
     
    189189class SearchFieldsBadTwo(models.Model): 
    190190    "Test search_fields, must be a field." 
    191     first_name = models.CharField(maxlength=30) 
     191    first_name = models.CharField(max_length=30) 
    192192 
    193193    def _last_name(self): 
     
    204204class SearchFieldsGood(models.Model): 
    205205    "Test search_fields, must be a list or tuple." 
    206     first_name = models.CharField(maxlength=30) 
    207     last_name = models.CharField(maxlength=30) 
     206    first_name = models.CharField(max_length=30) 
     207    last_name = models.CharField(max_length=30) 
    208208     
    209209    class Admin: 
     
    213213class JsBadOne(models.Model): 
    214214    "Test js, must be a list or tuple" 
    215     name = models.CharField(maxlength=30) 
     215    name = models.CharField(max_length=30) 
    216216     
    217217    class Admin: 
     
    224224class SaveAsBad(models.Model): 
    225225    "Test save_as, should be True or False" 
    226     name = models.CharField(maxlength=30) 
     226    name = models.CharField(max_length=30) 
    227227     
    228228    class Admin: 
     
    235235class SaveOnTopBad(models.Model): 
    236236    "Test save_on_top, should be True or False" 
    237     name = models.CharField(maxlength=30) 
     237    name = models.CharField(max_length=30) 
    238238     
    239239    class Admin: 
     
    246246class ListSelectRelatedBad(models.Model): 
    247247    "Test list_select_related, should be True or False" 
    248     name = models.CharField(maxlength=30) 
     248    name = models.CharField(max_length=30) 
    249249     
    250250    class Admin: 
     
    257257class ListPerPageBad(models.Model): 
    258258    "Test list_per_page, should be a positive integer value." 
    259     name = models.CharField(maxlength=30) 
     259    name = models.CharField(max_length=30) 
    260260     
    261261    class Admin: 
     
    268268class FieldsBadOne(models.Model): 
    269269    "Test fields, should be a tuple" 
    270     first_name = models.CharField(maxlength=30) 
    271     last_name = models.CharField(maxlength=30) 
     270    first_name = models.CharField(max_length=30) 
     271    last_name = models.CharField(max_length=30) 
    272272     
    273273    class Admin: 
     
    280280class FieldsBadTwo(models.Model): 
    281281    """Test fields, 'fields' dict option is required.""" 
    282     first_name = models.CharField(maxlength=30) 
    283     last_name = models.CharField(maxlength=30) 
     282    first_name = models.CharField(max_length=30) 
     283    last_name = models.CharField(max_length=30) 
    284284     
    285285    class Admin: 
     
    292292class FieldsBadThree(models.Model): 
    293293    """Test fields, 'classes' and 'description' are the only allowable extra dict options.""" 
    294     first_name = models.CharField(maxlength=30) 
    295     last_name = models.CharField(maxlength=30) 
     294    first_name = models.CharField(max_length=30) 
     295    last_name = models.CharField(max_length=30) 
    296296     
    297297    class Admin: 
     
    304304class FieldsGood(models.Model): 
    305305    "Test fields, working example" 
    306     first_name = models.CharField(maxlength=30) 
    307     last_name = models.CharField(maxlength=30) 
     306    first_name = models.CharField(max_length=30) 
     307    last_name = models.CharField(max_length=30) 
    308308    birth_day = models.DateField() 
    309309     
     
    316316class OrderingBad(models.Model): 
    317317    "Test ordering, must be a field." 
    318     first_name = models.CharField(maxlength=30) 
    319     last_name = models.CharField(maxlength=30) 
     318    first_name = models.CharField(max_length=30) 
     319    last_name = models.CharField(max_length=30) 
    320320     
    321321    class Admin: 
     
    329329#class ManagerBad(models.Model): 
    330330#    "Test manager, must be a manager object." 
    331 #    first_name = models.CharField(maxlength=30) 
     331#    first_name = models.CharField(max_length=30) 
    332332#     
    333333#    class Admin: 
  • django/branches/schema-evolution/tests/regressiontests/many_to_one_regress/models.py

    r5734 r5822  
    1313# Protect against repetition of #1839, #2415 and #2536. 
    1414class Third(models.Model): 
    15     name = models.CharField(maxlength=20) 
     15    name = models.CharField(max_length=20) 
    1616    third = models.ForeignKey('self', null=True, related_name='child_set') 
    1717 
    1818class Parent(models.Model): 
    19     name = models.CharField(maxlength=20) 
     19    name = models.CharField(max_length=20) 
    2020    bestchild = models.ForeignKey('Child', null=True, related_name='favored_by') 
    2121 
    2222class Child(models.Model): 
    23     name = models.CharField(maxlength=20) 
     23    name = models.CharField(max_length=20) 
    2424    parent = models.ForeignKey(Parent) 
    2525 
  • django/branches/schema-evolution/tests/regressiontests/model_regress/models.py

    r5734 r5822  
    88 
    99class Article(models.Model): 
    10     headline = models.CharField(maxlength=100, default='Default headline') 
     10    headline = models.CharField(max_length=100, default='Default headline') 
    1111    pub_date = models.DateTimeField() 
    1212    status = models.IntegerField(blank=True, null=True, choices=CHOICES) 
  • django/branches/schema-evolution/tests/regressiontests/null_queries/models.py

    r5734 r5822  
    22 
    33class Poll(models.Model): 
    4     question = models.CharField(maxlength=200) 
     4    question = models.CharField(max_length=200) 
    55 
    66    def __unicode__(self): 
     
    99class Choice(models.Model): 
    1010    poll = models.ForeignKey(Poll) 
    11     choice = models.CharField(maxlength=200) 
     11    choice = models.CharField(max_length=200) 
    1212 
    1313    def __unicode__(self): 
  • django/branches/schema-evolution/tests/regressiontests/one_to_one_regress/models.py

    r5734 r5822  
    22 
    33class Place(models.Model): 
    4     name = models.CharField(maxlength=50) 
    5     address = models.CharField(maxlength=80) 
     4    name = models.CharField(max_length=50) 
     5    address = models.CharField(max_length=80) 
    66 
    77    def __unicode__(self): 
     
    1717 
    1818class Favorites(models.Model): 
    19     name = models.CharField(maxlength = 50) 
     19    name = models.CharField(max_length = 50) 
    2020    restaurants = models.ManyToManyField(Restaurant) 
    2121 
  • django/branches/schema-evolution/tests/regressiontests/serializers_regress/models.py

    r5734 r5822  
    1717 
    1818class CharData(models.Model): 
    19     data = models.CharField(maxlength=30, null=True) 
     19    data = models.CharField(max_length=30, null=True) 
    2020 
    2121class DateData(models.Model): 
     
    9191 
    9292class GenericData(models.Model): 
    93     data = models.CharField(maxlength=30) 
     93    data = models.CharField(max_length=30) 
    9494 
    9595    tags = generic.GenericRelation(Tag) 
     
    103103    something for other models to point at""" 
    104104     
    105     data = models.CharField(maxlength=30) 
     105    data = models.CharField(max_length=30) 
    106106 
    107107class UniqueAnchor(models.Model): 
     
    109109    something for other models to point at""" 
    110110 
    111     data = models.CharField(unique=True, maxlength=30) 
     111    data = models.CharField(unique=True, max_length=30) 
    112112     
    113113class FKData(models.Model): 
     
    145145     
    146146class CharPKData(models.Model): 
    147     data = models.CharField(maxlength=30, primary_key=True) 
     147    data = models.CharField(max_length=30, primary_key=True) 
    148148 
    149149# class DatePKData(models.Model): 
     
    209209 
    210210class ComplexModel(models.Model): 
    211     field1 = models.CharField(maxlength=10) 
    212     field2 = models.CharField(maxlength=10) 
    213     field3 = models.CharField(maxlength=10) 
     211    field1 = models.CharField(max_length=10) 
     212    field2 = models.CharField(max_length=10) 
     213    field3 = models.CharField(max_length=10) 
    214214 
    215215# Tests for handling fields with pre_save functions, or 
  • django/branches/schema-evolution/tests/regressiontests/string_lookup/models.py

    r5734 r5822  
    33 
    44class Foo(models.Model): 
    5     name = models.CharField(maxlength=50) 
    6     friend = models.CharField(maxlength=50, blank=True) 
     5    name = models.CharField(max_length=50) 
     6    friend = models.CharField(max_length=50, blank=True) 
    77 
    88    def __unicode__(self): 
     
    1010 
    1111class Bar(models.Model): 
    12     name = models.CharField(maxlength=50) 
     12    name = models.CharField(max_length=50) 
    1313    normal = models.ForeignKey(Foo, related_name='normal_foo') 
    1414    fwd = models.ForeignKey("Whiz") 
     
    1919 
    2020class Whiz(models.Model): 
    21     name = models.CharField(maxlength = 50) 
     21    name = models.CharField(max_length = 50) 
    2222 
    2323    def __unicode__(self): 
     
    2626class Child(models.Model): 
    2727    parent = models.OneToOneField('Base') 
    28     name = models.CharField(maxlength = 50) 
     28    name = models.CharField(max_length = 50) 
    2929 
    3030    def __unicode__(self): 
     
    3232 
    3333class Base(models.Model): 
    34     name = models.CharField(maxlength = 50) 
     34    name = models.CharField(max_length = 50) 
    3535 
    3636    def __unicode__(self):