Django

Code

Changeset 4973

Show
Ignore:
Timestamp:
04/09/07 06:09:17 (2 years ago)
Author:
mtredinnick
Message:

unicode: Merged with trunk up to [4970].

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/unicode

    • Property svnmerge-integrated changed from /django/trunk:1-4951 to /django/trunk:1-4971
  • django/branches/unicode/AUTHORS

    r4937 r4973  
    8989    Marc Fargas <telenieko@telenieko.com> 
    9090    favo@exoweb.net 
     91    Matthew Flanagan <http://wadofstuff.blogspot.com> 
    9192    Eric Floehr <eric@intellovations.com> 
    9293    Jorge Gajon <gajon@gajon.org> 
  • django/branches/unicode/django/contrib/localflavor/br/br_states.py

    r4874 r4973  
    11# -*- coding: utf-8 -*- 
    22""" 
    3 A brazilian mapping of state misspellings/abbreviations to normalized 
    4 abbreviations, and an alphabetical list of states for use as `choices 
    5 in a formfield. 
     3An alphabetical list of Brazilian states for use as `choices` in a formfield. 
    64 
    7 This exists in this standalone file so that it's only imported into 
    8 memory when explicitly needed. 
     5This exists in this standalone file so that it's only imported into memory 
     6when explicitly needed. 
    97""" 
    108 
  • django/branches/unicode/django/contrib/localflavor/fi/forms.py

    r4868 r4973  
    2727        super(FISocialSecurityNumber, self).clean(value) 
    2828        if value in EMPTY_VALUES: 
    29                return u'' 
    30          
     29            return u'' 
     30 
    3131        checkmarks = "0123456789ABCDEFHJKLMNPRSTUVWXY" 
    3232        result = re.match(r"""^ 
     
    3636            [A+-] 
    3737            (?P<serial>(\d{3})) 
    38             (?P<chechsum>[%s])$""" % checkmarks, value, re.VERBOSE | re.IGNORECASE) 
     38            (?P<checksum>[%s])$""" % checkmarks, value, re.VERBOSE | re.IGNORECASE) 
    3939        if not result: 
    4040            raise ValidationError(gettext(u'Enter a valid Finnish social security number.')) 
    41         checksum = int(result.groupdict()['date'] + result.groupdict()['serial']
    42  
    43         if checkmarks[checksum % len(checkmarks)] == result.groupdict()['chechsum'].upper(): 
     41        gd = result.groupdict(
     42        checksum = int(gd['date'] + gd['serial']) 
     43        if checkmarks[checksum % len(checkmarks)] == gd['checksum'].upper(): 
    4444            return u'%s' % value.upper() 
    45          
    4645        raise ValidationError(gettext(u'Enter a valid Finnish social security number.')) 
    47  
  • django/branches/unicode/django/db/models/fields/__init__.py

    r4752 r4973  
    762762 
    763763    def formfield(self, **kwargs): 
    764         from django.contrib.localflavor.usa.forms import USPhoneNumberField 
     764        from django.contrib.localflavor.us.forms import USPhoneNumberField 
    765765        defaults = {'required': not self.blank, 'label': capfirst(self.verbose_name), 'help_text': self.help_text} 
    766766        defaults.update(kwargs) 
  • django/branches/unicode/django/newforms/widgets.py

    r4918 r4973  
    122122 
    123123class Textarea(Widget): 
     124    def __init__(self, attrs=None): 
     125        # The 'rows' and 'cols' attributes are required for HTML correctness. 
     126        self.attrs = {'cols': '40', 'rows': '10'} 
     127        if attrs: 
     128            self.attrs.update(attrs) 
     129 
    124130    def render(self, name, value, attrs=None): 
    125131        if value is None: value = '' 
  • django/branches/unicode/django/views/debug.py

    r4265 r4973  
    145145    c = Context({ 
    146146        'root_urlconf': settings.ROOT_URLCONF, 
     147        'request_path': request.path[1:], # Trim leading slash 
    147148        'urlpatterns': tried, 
    148149        'reason': str(exception), 
     
    592593        {% endfor %} 
    593594      </ol> 
    594       <p>The current URL, <code>{{ request.path|escape }}</code>, didn't match any of these.</p> 
     595      <p>The current URL, <code>{{ request_path|escape }}</code>, didn't match any of these.</p> 
    595596    {% else %} 
    596597      <p>{{ reason|escape }}</p> 
  • django/branches/unicode/docs/django-admin.txt

    r4937 r4973  
    3030Django settings files. 
    3131 
     32The command-line examples throughout this document use ``django-admin.py`` to 
     33be consistent, but any example can use ``manage.py`` just as well. 
     34 
    3235Usage 
    3336===== 
     
    101104------------------------------ 
    102105 
    103 Output to standard output all data in the database associated with the named  
     106Output to standard output all data in the database associated with the named 
    104107application(s). 
    105108 
    106109By default, the database will be dumped in JSON format. If you want the output 
    107 to be in another format, use the ``--format`` option (e.g., ``format=xml``).  
    108 You may specify any Django serialization backend (including any user specified  
     110to be in another format, use the ``--format`` option (e.g., ``format=xml``). 
     111You may specify any Django serialization backend (including any user specified 
    109112serialization backends named in the ``SERIALIZATION_MODULES`` setting). 
    110113 
    111114If no application name is provided, all installed applications will be dumped. 
    112115 
    113 The output of ``dumpdata`` can be used as input for ``loaddata``.  
     116The output of ``dumpdata`` can be used as input for ``loaddata``. 
    114117 
    115118flush 
    116119----- 
    117120 
    118 Return the database to the state it was in immediately after syncdb was  
    119 executed. This means that all data will be removed from the database, any  
     121Return the database to the state it was in immediately after syncdb was 
     122executed. This means that all data will be removed from the database, any 
    120123post-synchronization handlers will be re-executed, and the ``initial_data`` 
    121124fixture will be re-installed. 
     
    179182 
    180183Django will load any and all fixtures it finds in these locations that match 
    181 the provided fixture names.  
    182  
    183 If the named fixture has a file extension, only fixtures of that type  
     184the provided fixture names. 
     185 
     186If the named fixture has a file extension, only fixtures of that type 
    184187will be loaded. For example:: 
    185188 
    186189    django-admin.py loaddata mydata.json 
    187      
    188 would only load JSON fixtures called ``mydata``. The fixture extension  
    189 must correspond to the registered name of a serializer (e.g., ``json`` or  
     190 
     191would only load JSON fixtures called ``mydata``. The fixture extension 
     192must correspond to the registered name of a serializer (e.g., ``json`` or 
    190193``xml``). 
    191194 
    192 If you omit the extension, Django will search all available fixture types  
     195If you omit the extension, Django will search all available fixture types 
    193196for a matching fixture. For example:: 
    194197 
    195198    django-admin.py loaddata mydata 
    196      
     199 
    197200would look for any fixture of any fixture type called ``mydata``. If a fixture 
    198201directory contained ``mydata.json``, that fixture would be loaded 
    199 as a JSON fixture. However, if two fixtures with the same name but different  
    200 fixture type are discovered (for example, if ``mydata.json`` and  
    201 ``mydata.xml`` were found in the same fixture directory), fixture  
    202 installation will be aborted, and any data installed in the call to  
     202as a JSON fixture. However, if two fixtures with the same name but different 
     203fixture type are discovered (for example, if ``mydata.json`` and 
     204``mydata.xml`` were found in the same fixture directory), fixture 
     205installation will be aborted, and any data installed in the call to 
    203206``loaddata`` will be removed from the database. 
    204207 
    205 The fixtures that are named can include directory components. These  
     208The fixtures that are named can include directory components. These 
    206209directories will be included in the search path. For example:: 
    207210 
    208211    django-admin.py loaddata foo/bar/mydata.json 
    209   
    210 would search ``<appname>/fixtures/foo/bar/mydata.json`` for each installed  
    211 application,  ``<dirname>/foo/bar/mydata.json`` for each directory in  
     212 
     213would search ``<appname>/fixtures/foo/bar/mydata.json`` for each installed 
     214application,  ``<dirname>/foo/bar/mydata.json`` for each directory in 
    212215``FIXTURE_DIRS``, and the literal path ``foo/bar/mydata.json``. 
    213216 
     
    220223.. admonition:: MySQL and Fixtures 
    221224 
    222     Unfortunately, MySQL isn't capable of completely supporting all the  
     225    Unfortunately, MySQL isn't capable of completely supporting all the 
    223226    features of Django fixtures. If you use MyISAM tables, MySQL doesn't 
    224     support transactions or constraints, so you won't get a rollback if  
    225     multiple transaction files are found, or validation of fixture data.  
    226     If you use InnoDB tables, you won't be able to have any forward  
    227     references in your data files - MySQL doesn't provide a mechanism to  
    228     defer checking of row constraints until a transaction is committed.     
    229      
     227    support transactions or constraints, so you won't get a rollback if 
     228    multiple transaction files are found, or validation of fixture data. 
     229    If you use InnoDB tables, you won't be able to have any forward 
     230    references in your data files - MySQL doesn't provide a mechanism to 
     231    defer checking of row constraints until a transaction is committed. 
     232 
    230233reset [appname appname ...] 
    231234--------------------------- 
     
    398401give you the option of creating a superuser immediately. 
    399402 
    400 ``syncdb`` will also search for and install any fixture named ``initial_data``.  
    401 See the documentation for ``loaddata`` for details on the specification of  
     403``syncdb`` will also search for and install any fixture named ``initial_data``. 
     404See the documentation for ``loaddata`` for details on the specification of 
    402405fixture data files. 
    403406 
     
    472475    django-admin.py dumpdata --indent=4 
    473476 
    474 Specifies the number of spaces that will be used for indentation when  
     477Specifies the number of spaces that will be used for indentation when 
    475478pretty-printing output. By default, output will *not* be pretty-printed. 
    476479Pretty-printing will only be enabled if the indent option is provided. 
     
    513516 
    514517Example usage:: 
    515     django-admin.py manage.py --adminmedia=/tmp/new-admin-style/ 
     518 
     519    django-admin.py --adminmedia=/tmp/new-admin-style/ 
    516520 
    517521Tells Django where to find the various CSS and JavaScript files for the admin 
  • django/branches/unicode/docs/documentation.txt

    r3561 r4973  
    4343The most recent version of the Django documentation lives at 
    4444http://www.djangoproject.com/documentation/ . These HTML pages are generated 
    45 automatically from the text files in source control every 15 minutes. Tha
    46 means they reflect the "latest and greatest" in Django -- they include the very 
    47 latest corrections and additions, and they discuss the latest Django features, 
     45automatically from the text files in source control. That means they reflec
     46the "latest and greatest" in Django -- they include the very latest 
     47corrections and additions, and they discuss the latest Django features, 
    4848which may only be available to users of the Django development version. (See 
    4949"Differences between versions" below.) 
    5050 
    51 A key advantage of the Web-based documentation is the comment section at the 
    52 bottom of each document. This is an area for anybody to submit changes, 
    53 corrections and suggestions about the given document. The Django developers 
    54 frequently monitor the comments there and use them to improve the documentation 
    55 for everybody. 
     51We encourage you to help improve the docs by submitting changes, corrections 
     52and suggestions in the `ticket system`_. The Django developers actively monitor 
     53the ticket system and use your feedback to improve the documentation for 
     54everybody. 
    5655 
    57 We encourage you to help improve the docs: it's easy! Note, however, that 
    58 comments should explicitly relate to the documentation, rather than asking 
    59 broad tech-support questions. If you need help with your particular Django 
    60 setup, try the `django-users mailing list`_ instead of posting a comment to the 
    61 documentation. 
     56Note, however, that tickets should explicitly relate to the documentation, 
     57rather than asking broad tech-support questions. If you need help with your 
     58particular Django setup, try the `django-users mailing list`_ or the 
     59`#django IRC channel`_ instead. 
    6260 
     61.. _ticket system: http://code.djangoproject.com/simpleticket?component=Documentation 
    6362.. _django-users mailing list: http://groups.google.com/group/django-users 
     63.. _#django IRC channel: irc://irc.freenode.net/django 
    6464 
    6565In plain text 
     
    135135      and links to the current version of that document. 
    136136 
    137     * Once a document is frozen for a Django release, we remove comments from 
    138       that page, in favor of having comments on the latest version of that 
    139       document. This is for the sake of maintainability and usability, so that 
    140       users have one, and only one, place to leave comments on a particular 
    141       document. We realize that some people may be stuck on a previous version 
    142       of Django, but we believe the usability problems with multiple versions 
    143       of a document the outweigh the benefits. 
    144  
    145137    * The `main documentation Web page`_ includes links to documentation for 
    146138      all previous versions. 
  • django/branches/unicode/docs/legacy_databases.txt

    r4420 r4973  
    4040database. You can view the output by running this command:: 
    4141 
    42     django-admin.py inspectdb --settings=path.to.settings 
     42    python manage.py inspectdb 
    4343 
    4444Save this as a file by using standard Unix output redirection:: 
    4545 
    46     django-admin.py inspectdb --settings=path.to.settings > models.py 
     46    python manage.py inspectdb > models.py 
    4747 
    4848This feature is meant as a shortcut, not as definitive model generation. See 
     
    6161records such as admin permissions and content types:: 
    6262 
    63     django-admin.py init --settings=path.to.settings 
     63    python manage.py syncdb 
    6464 
    6565See whether it worked 
  • django/branches/unicode/docs/modpython.txt

    r4897 r4973  
    5858.. caution:: 
    5959 
    60     Is you are using Windows, remember that the path will contain backslashes. 
     60    If you're using Windows, remember that the path will contain backslashes. 
    6161    This string is passed through Python's string parser twice, so you need to 
    6262    escape each backslash **twice**:: 
     
    6464        PythonPath "['c:\\\\path\\\\to\\\\project'] + sys.path" 
    6565 
    66     or use raw strings:: 
     66    Or, use raw strings:: 
    6767 
    6868        PythonPath "[r'c:\\path\\to\\project'] + sys.path" 
    69  
    7069 
    7170You can also add directives such as ``PythonAutoReload Off`` for performance. 
     
    162161particular part of the site:: 
    163162 
    164     <Location "/media/"> 
     163    <Location "/media"> 
    165164        SetHandler None 
    166165    </Location> 
     
    179178    </Location> 
    180179 
    181     <Location "media"> 
     180    <Location "/media"> 
    182181        SetHandler None 
    183182    </Location> 
  • django/branches/unicode/docs/request_response.txt

    r4890 r4973  
    484484called ``404.html`` and located in the top level of your template tree. 
    485485 
    486 Customing error views 
    487 --------------------- 
     486Customizing error views 
     487----------------------- 
    488488 
    489489The 404 (page not found) view 
  • django/branches/unicode/docs/url_dispatch.txt

    r4903 r4973  
    193193url 
    194194--- 
    195 **New in development version** 
    196  
    197 The ``url()`` function can be used instead of a tuple as an argument to 
    198 ``patterns()``. This is convenient if you wish to specify a name without the 
     195 
     196**New in Django development version** 
     197 
     198You can use the ``url()`` function, instead of a tuple, as an argument to 
     199``patterns()``. This is convenient if you want to specify a name without the 
    199200optional extra arguments dictionary. For example:: 
    200201 
     
    499500=================== 
    500501 
    501 **New in development version** 
    502  
    503 It is fairly common to use the same view function in multiple URL patterns in 
    504 your URLConf. This leads to problems when you come to do reverse URL matching, 
    505 because the ``permalink()`` decorator and ``{% url %}`` template tag use the 
    506 name of the view function to find a match. 
    507  
    508 To solve this problem, you can give a name to each of your URL patterns in 
    509 order to distinguish them from other patterns using the same views and 
    510 parameters. You can then use this name wherever you would otherwise use the 
    511 name of the view function. For example, if you URLConf contains:: 
     502**New in Django development version** 
     503 
     504It's fairly common to use the same view function in multiple URL patterns in 
     505your URLconf. For example, these two URL patterns both point to the ``archive`` 
     506view:: 
     507 
     508    urlpatterns = patterns('', 
     509        (r'/archive/(\d{4})/$', archive), 
     510        (r'/archive-summary/(\d{4})/$', archive, {'summary': True}), 
     511    ) 
     512 
     513This is completely valid, but it leads to problems when you try to do reverse 
     514URL matching (through the ``permalink()`` decorator or the ``{% url %}`` 
     515template tag). Continuing this example, if you wanted to retrieve the URL for 
     516the ``archive`` view, Django's reverse URL matcher would get confused, because 
     517*two* URLpatterns point at that view. 
     518 
     519To solve this problem, Django supports **named URL patterns**. That is, you can 
     520give a name to a URL pattern in order to distinguish it from other patterns 
     521using the same view and parameters. Then, you can use this name in reverse URL 
     522matching. 
     523 
     524Here's the above example, rewritten to used named URL patterns:: 
    512525 
    513526    urlpatterns = patterns('', 
     
    516529    ) 
    517530 
    518 ...you could refer to either the summary archive view in a template as:: 
     531With these names in place (``full-archive`` and ``arch-summary``), you can 
     532target each pattern individually by using its name:: 
    519533 
    520534    {% url arch-summary 1945 %} 
     535    {% url full-archive 2007 %} 
    521536 
    522537Even though both URL patterns refer to the ``archive`` view here, using the 
     
    528543.. note:: 
    529544 
    530     Make sure that when you name your URLs, you use names that are unlikely to 
    531     clash with any other application's choice of names. If you call your URL 
    532     pattern *comment* and another application does the same thing, there is no 
    533     guarantee which URL will be inserted into your template when you use this 
    534     name. Putting a prefix on your URL names, perhaps derived from 
    535     the application name, will decrease the chances of collision. Something 
    536     like *myapp-comment* is recommended over simply *comment*. 
    537  
     545    When you name your URL patterns, make sure you use names that are unlikely 
     546    to clash with any other application's choice of names. If you call your URL 
     547    pattern ``comment``, and another application does the same thing, there's 
     548    no guarantee which URL will be inserted into your template when you use 
     549    this name. 
     550 
     551    Putting a prefix on your URL names, perhaps derived from the application 
     552    name, will decrease the chances of collision. We recommend something like 
     553    ``myapp-comment`` instead of ``comment``. 
  • django/branches/unicode/tests/modeltests/model_forms/models.py

    r4971 r4973  
    160160<option value="2">Bob Woodward</option> 
    161161</select></td></tr> 
    162 <tr><th>Article:</th><td><textarea name="article"></textarea></td></tr> 
     162<tr><th>Article:</th><td><textarea rows="10" cols="40" name="article"></textarea></td></tr> 
    163163<tr><th>Categories:</th><td><select multiple="multiple" name="categories"> 
    164164<option value="1">Entertainment</option> 
     
    200200<option value="2">Bob Woodward</option> 
    201201</select></li> 
    202 <li>Article: <textarea name="article">Hello.</textarea></li> 
     202<li>Article: <textarea rows="10" cols="40" name="article">Hello.</textarea></li> 
    203203<li>Categories: <select multiple="multiple" name="categories"> 
    204204<option value="1">Entertainment</option> 
     
    232232<option value="2">Bob Woodward</option> 
    233233</select></li> 
    234 <li>Article: <textarea name="article">Hello.</textarea></li> 
     234<li>Article: <textarea rows="10" cols="40" name="article">Hello.</textarea></li> 
    235235<li>Categories: <select multiple="multiple" name="categories"> 
    236236<option value="1" selected="selected">Entertainment</option> 
     
    310310<option value="2">Bob Woodward</option> 
    311311</select></li> 
    312 <li>Article: <textarea name="article"></textarea></li> 
     312<li>Article: <textarea rows="10" cols="40" name="article"></textarea></li> 
    313313<li>Categories: <select multiple="multiple" name="categories"> 
    314314<option value="1">Entertainment</option> 
     
    329329<option value="3">Carl Bernstein</option> 
    330330</select></li> 
    331 <li>Article: <textarea name="article"></textarea></li> 
     331<li>Article: <textarea rows="10" cols="40" name="article"></textarea></li> 
    332332<li>Categories: <select multiple="multiple" name="categories"> 
    333333<option value="1">Entertainment</option> 
  • django/branches/unicode/tests/regressiontests/forms/localflavor.py

    r4939 r4973  
    77USZipCodeField validates that the data is either a five-digit U.S. zip code or 
    88a zip+4. 
    9 >>> from django.contrib.localflavor.usa.forms import USZipCodeField 
     9>>> from django.contrib.localflavor.us.forms import USZipCodeField 
    1010>>> f = USZipCodeField() 
    1111>>> f.clean('60606') 
     
    6868USPhoneNumberField validates that the data is a valid U.S. phone number, 
    6969including the area code. It's normalized to XXX-XXX-XXXX format. 
    70 >>> from django.contrib.localflavor.usa.forms import USPhoneNumberField 
     70>>> from django.contrib.localflavor.us.forms import USPhoneNumberField 
    7171>>> f = USPhoneNumberField() 
    7272>>> f.clean('312-555-1212') 
     
    137137USStateField validates that the data is either an abbreviation or name of a 
    138138U.S. state. 
    139 >>> from django.contrib.localflavor.usa.forms import USStateField 
     139>>> from django.contrib.localflavor.us.forms import USStateField 
    140140>>> f = USStateField() 
    141141>>> f.clean('il') 
     
    182182USStateSelect is a Select widget that uses a list of U.S. states/territories 
    183183as its choices. 
    184 >>> from django.contrib.localflavor.usa.forms import USStateSelect 
     184>>> from django.contrib.localflavor.us.forms import USStateSelect 
    185185>>> w = USStateSelect() 
    186186>>> print w.render('state', 'IL') 
     
    248248 
    249249# USSocialSecurityNumberField ################################################# 
    250 >>> from django.contrib.localflavor.usa.forms import USSocialSecurityNumberField 
     250>>> from django.contrib.localflavor.us.forms import USSocialSecurityNumberField 
    251251>>> f = USSocialSecurityNumberField() 
    252252>>> f.clean('987-65-4330') 
     
    883883... 
    884884ValidationError: [u'Enter a valid German identity card number in XXXXXXXXXXX-XXXXXXX-XXXXXXX-X format.'] 
     885 
     886## AUPostCodeField ########################################################## 
     887 
     888A field that accepts a four digit Australian post code. 
     889 
     890>>> from django.contrib.localflavor.au.forms import AUPostCodeField 
     891>>> f = AUPostCodeField() 
     892>>> f.clean('1234') 
     893u'1234' 
     894>>> f.clean('2000') 
     895u'2000' 
     896>>> f.clean('abcd') 
     897Traceback (most recent call last): 
     898... 
     899ValidationError: [u'Enter a 4 digit post code.'] 
     900>>> f.clean('20001') 
     901Traceback (most recent call last): 
     902... 
     903ValidationError: [u'Enter a 4 digit post code.'] 
     904>>> f.clean(None) 
     905Traceback (most recent call last): 
     906... 
     907ValidationError: [u'This field is required.'] 
     908>>> f.clean('') 
     909Traceback (most recent call last): 
     910... 
     911ValidationError: [u'This field is required.'] 
     912 
     913>>> f = AUPostCodeField(required=False) 
     914>>> f.clean('1234') 
     915u'1234' 
     916>>> f.clean('2000') 
     917u'2000' 
     918>>> f.clean('abcd') 
     919Traceback (most recent call last): 
     920... 
     921ValidationError: [u'Enter a 4 digit post code.'] 
     922>>> f.clean('20001') 
     923Traceback (most recent call last): 
     924... 
     925ValidationError: [u'Enter a 4 digit post code.'] 
     926>>> f.clean(None) 
     927u'' 
     928>>> f.clean('') 
     929u'' 
     930 
     931## AUPhoneNumberField ######################################################## 
     932 
     933A field that accepts a 10 digit Australian phone number. 
     934llows spaces and parentheses around area code. 
     935 
     936>>> from django.contrib.localflavor.au.forms import AUPhoneNumberField 
     937>>> f = AUPhoneNumberField() 
     938>>> f.clean('1234567890') 
     939u'1234567890' 
     940>>> f.clean('0213456789') 
     941u'0213456789' 
     942>>> f.clean('02 13 45 67 89') 
     943u'0213456789' 
     944>>> f.clean('(02) 1345 6789') 
     945u'0213456789' 
     946>>> f.clean('(02) 1345-6789') 
     947u'0213456789' 
     948>>> f.clean('(02)1345-6789') 
     949u'0213456789' 
     950>>> f.clean('0408 123 456') 
     951u'0408123456' 
     952>>> f.clean('123') 
     953Traceback (most recent call last): 
     954... 
     955ValidationError: [u'Phone numbers must contain 10 digits.'] 
     956>>> f.clean('1800DJANGO') 
     957Traceback (most recent call last): 
     958... 
     959ValidationError: [u'Phone numbers must contain 10 digits.'] 
     960>>> f.clean(None) 
     961Traceback (most recent call last): 
     962... 
     963ValidationError: [u'This field is required.'] 
     964>>> f.clean('') 
     965Traceback (most recent call last): 
     966... 
     967ValidationError: [u'This field is required.'] 
     968 
     969>>> f = AUPhoneNumberField(required=False) 
     970>>> f.clean('1234567890') 
     971u'1234567890' 
     972>>> f.clean('0213456789') 
     973u'0213456789' 
     974>>> f.clean('02 13 45 67 89') 
     975u'0213456789' 
     976>>> f.clean('(02) 1345 6789') 
     977u'0213456789' 
     978>>> f.clean('(02) 1345-6789') 
     979u'0213456789' 
     980>>> f.clean('(02)1345-6789') 
     981u'0213456789' 
     982>>> f.clean('0408 123 456') 
     983u'0408123456' 
     984>>> f.clean('123') 
     985Traceback (most recent call last): 
     986... 
     987ValidationError: [u'Phone numbers must contain 10 digits.'] 
     988>>> f.clean('1800DJANGO') 
     989Traceback (most recent call last): 
     990... 
     991ValidationError: [u'Phone numbers must contain 10 digits.'] 
     992>>> f.clean(None) 
     993u'' 
     994>>> f.clean('') 
     995u'' 
     996 
     997## AUStateSelect ############################################################# 
     998 
     999AUStateSelect is a Select widget that uses a list of Australian 
     1000states/territories as its choices. 
     1001 
     1002>>> from django.contrib.localflavor.au.forms import AUStateSelect 
     1003>>> f = AUStateSelect() 
     1004>>> print f.render('state', 'NSW') 
     1005<select name="state"> 
     1006<option value="ACT">Australian Capital Territory</option> 
     1007<option value="NSW" selected="selected">New South Wales</option> 
     1008<option value="NT">Northern Territory</option> 
     1009<option value="QLD">Queensland</option> 
     1010<option value="SA">South Australia</option> 
     1011<option value="TAS">Tasmania</option> 
     1012<option value="VIC">Victoria</option> 
     1013<option value="WA">Western Australia</option> 
     1014</select> 
    8851015""" 
  • django/branches/unicode/tests/regressiontests/forms/tests.py

    r4930 r4973  
    194194>>> w = Textarea() 
    195195>>> w.render('msg', '') 
    196 u'<textarea name="msg"></textarea>' 
     196u'<textarea rows="10" cols="40" name="msg"></textarea>' 
    197197>>> w.render('msg', None) 
    198 u'<textarea name="msg"></textarea>' 
     198u'<textarea rows="10" cols="40" name="msg"></textarea>' 
    199199>>> w.render('msg', 'value') 
    200 u'<textarea name="msg">value</textarea>' 
     200u'<textarea rows="10" cols="40" name="msg">value</textarea>' 
    201201>>> w.render('msg', 'some "quoted" & ampersanded value') 
    202 u'<textarea name="msg">some &quot;quoted&quot; &amp; ampersanded value</textarea>' 
    203 >>> w.render('msg', 'value', attrs={'class': 'pretty'}) 
    204 u'<textarea name="msg" class="pretty">value</textarea>' 
     202u'<textarea rows="10" cols="40" name="msg">some &quot;quoted&quot; &amp; ampersanded value</textarea>' 
     203>>> w.render('msg', 'value', attrs={'class': 'pretty', 'rows': 20}) 
     204u'<textarea class="pretty" rows="20" cols="40" name="msg">value</textarea>' 
    205205 
    206206You can also pass 'attrs' to the constructor: 
    207207>>> w = Textarea(attrs={'class': 'pretty'}) 
    208208>>> w.render('msg', '') 
    209 u'<textarea class="pretty" name="msg"></textarea>' 
     209u'<textarea rows="10" cols="40" name="msg" class="pretty"></textarea>' 
    210210>>> w.render('msg', 'example') 
    211 u'<textarea class="pretty" name="msg">example</textarea>' 
     211u'<textarea rows="10" cols="40" name="msg" class="pretty">example</textarea>' 
    212212 
    213213'attrs' passed to render() get precedence over those passed to the constructor: 
    214214>>> w = Textarea(attrs={'class': 'pretty'}) 
    215215>>> w.render('msg', '', attrs={'class': 'special'}) 
    216 u'<textarea class="special" name="msg"></textarea>' 
     216u'<textarea rows="10" cols="40" name="msg" class="special"></textarea>' 
    217217 
    218218>>> w.render('msg', 'ŠĐĆŽćžšđ', attrs={'class': 'fun'}) 
    219 u'<textarea class="fun" name="msg">\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111</textarea>' 
     219u'<textarea rows="10" cols="40" name="msg" class="fun">\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111</textarea>' 
    220220 
    221221# CheckboxInput Widget ######################################################## 
     
    19671967<input type="text" name="subject" /> 
    19681968>>> print f['message'] 
    1969 <textarea name="message"></textarea> 
     1969<textarea rows="10" cols="40" name="message"></textarea> 
    19701970 
    19711971as_textarea(), as_text() and as_hidden() are shortcuts for changing the output 
    19721972widget type: 
    19731973>>> f['subject'].as_textarea() 
    1974 u'<textarea name="subject"></textarea>' 
     1974u'<textarea rows="10" cols="40" name="subject"></textarea>' 
    19751975>>> f['message'].as_text() 
    19761976u'<input type="text" name="message" />' 
     
    19921992>>> f = ContactForm({'subject': 'Hello', 'message': 'I love you.'}, auto_id=False) 
    19931993>>> f['subject'].as_textarea() 
    1994 u'<textarea name="subject">Hello</textarea>' 
     1994u'<textarea rows="10" cols="40" name="subject">Hello</textarea>' 
    19951995>>> f['message'].as_text() 
    19961996u'<input type="text" name="message" value="I love you." />'