Changeset 4962
- Timestamp:
- 04/08/07 20:33:23 (2 years ago)
- Files:
-
- django/branches/newforms-admin (modified) (1 prop)
- django/branches/newforms-admin/AUTHORS (modified) (1 diff)
- django/branches/newforms-admin/django/contrib/localflavor/au (copied) (copied from django/trunk/django/contrib/localflavor/au)
- django/branches/newforms-admin/django/contrib/localflavor/au/au_states.py (copied) (copied from django/trunk/django/contrib/localflavor/au/au_states.py)
- django/branches/newforms-admin/django/contrib/localflavor/au/forms.py (copied) (copied from django/trunk/django/contrib/localflavor/au/forms.py)
- django/branches/newforms-admin/django/contrib/localflavor/au/__init__.py (copied) (copied from django/trunk/django/contrib/localflavor/au/__init__.py)
- django/branches/newforms-admin/django/contrib/localflavor/us (copied) (copied from django/trunk/django/contrib/localflavor/us)
- django/branches/newforms-admin/django/contrib/localflavor/usa (deleted)
- django/branches/newforms-admin/django/contrib/localflavor/us/forms.py (copied) (copied from django/trunk/django/contrib/localflavor/us/forms.py)
- django/branches/newforms-admin/django/contrib/localflavor/us/__init__.py (copied) (copied from django/trunk/django/contrib/localflavor/us/__init__.py)
- django/branches/newforms-admin/django/contrib/localflavor/us/us_states.py (copied) (copied from django/trunk/django/contrib/localflavor/us/us_states.py)
- django/branches/newforms-admin/django/db/models/fields/__init__.py (modified) (1 diff)
- django/branches/newforms-admin/django/newforms/widgets.py (modified) (1 diff)
- django/branches/newforms-admin/django/views/debug.py (modified) (2 diffs)
- django/branches/newforms-admin/docs/documentation.txt (modified) (2 diffs)
- django/branches/newforms-admin/docs/modpython.txt (modified) (4 diffs)
- django/branches/newforms-admin/docs/request_response.txt (modified) (1 diff)
- django/branches/newforms-admin/tests/modeltests/model_forms/models.py (modified) (5 diffs)
- django/branches/newforms-admin/tests/regressiontests/forms/localflavor.py (modified) (6 diffs)
- django/branches/newforms-admin/tests/regressiontests/forms/tests.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/newforms-admin
- Property svnmerge-integrated changed from /django/trunk:1-4345,4350-4357,4359-4365,4371-4372,4374-4377,4380-4386,4388,4390-4391,4400-4402,4404-4408,4410,4412-4419,4426-4427,4430-4432,4434,4441,4443-4444,4446-4447,4450,4452-4453,4455-4458,4476,4503,4546,4564-4569,4580-4586,4617,4630,4641-4945 to /django/trunk:1-4345,4350-4357,4359-4365,4371-4372,4374-4377,4380-4386,4388,4390-4391,4400-4402,4404-4408,4410,4412-4419,4426-4427,4430-4432,4434,4441,4443-4444,4446-4447,4450,4452-4453,4455-4458,4476,4503,4546,4564-4569,4580-4586,4617,4630,4641-4961
django/branches/newforms-admin/AUTHORS
r4940 r4962 89 89 Marc Fargas <telenieko@telenieko.com> 90 90 favo@exoweb.net 91 Matthew Flanagan <http://wadofstuff.blogspot.com> 91 92 Eric Floehr <eric@intellovations.com> 92 93 Jorge Gajon <gajon@gajon.org> django/branches/newforms-admin/django/db/models/fields/__init__.py
r4824 r4962 764 764 765 765 def formfield(self, **kwargs): 766 from django.contrib.localflavor.us a.forms import USPhoneNumberField766 from django.contrib.localflavor.us.forms import USPhoneNumberField 767 767 defaults = {'required': not self.blank, 'label': capfirst(self.verbose_name), 'help_text': self.help_text} 768 768 defaults.update(kwargs) django/branches/newforms-admin/django/newforms/widgets.py
r4940 r4962 122 122 123 123 class 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 124 130 def render(self, name, value, attrs=None): 125 131 if value is None: value = '' django/branches/newforms-admin/django/views/debug.py
r4265 r4962 145 145 c = Context({ 146 146 'root_urlconf': settings.ROOT_URLCONF, 147 'request_path': request.path[1:], # Trim leading slash 147 148 'urlpatterns': tried, 148 149 'reason': str(exception), … … 592 593 {% endfor %} 593 594 </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> 595 596 {% else %} 596 597 <p>{{ reason|escape }}</p> django/branches/newforms-admin/docs/documentation.txt
r3561 r4962 43 43 The most recent version of the Django documentation lives at 44 44 http://www.djangoproject.com/documentation/ . These HTML pages are generated 45 automatically from the text files in source control every 15 minutes. That46 means they reflect the "latest and greatest" in Django -- they include the very 47 latestcorrections and additions, and they discuss the latest Django features,45 automatically from the text files in source control. That means they reflect 46 the "latest and greatest" in Django -- they include the very latest 47 corrections and additions, and they discuss the latest Django features, 48 48 which may only be available to users of the Django development version. (See 49 49 "Differences between versions" below.) 50 50 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. 51 We encourage you to help improve the docs by submitting changes, corrections 52 and suggestions in the `ticket system`_. The Django developers actively monitor 53 the ticket system and use your feedback to improve the documentation for 54 everybody. 56 55 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. 56 Note, however, that tickets should explicitly relate to the documentation, 57 rather than asking broad tech-support questions. If you need help with your 58 particular Django setup, try the `django-users mailing list`_ or the 59 `#django IRC channel`_ instead. 62 60 61 .. _ticket system: http://code.djangoproject.com/simpleticket?component=Documentation 63 62 .. _django-users mailing list: http://groups.google.com/group/django-users 63 .. _#django IRC channel: irc://irc.freenode.net/django 64 64 65 65 In plain text … … 135 135 and links to the current version of that document. 136 136 137 * Once a document is frozen for a Django release, we remove comments from138 that page, in favor of having comments on the latest version of that139 document. This is for the sake of maintainability and usability, so that140 users have one, and only one, place to leave comments on a particular141 document. We realize that some people may be stuck on a previous version142 of Django, but we believe the usability problems with multiple versions143 of a document the outweigh the benefits.144 145 137 * The `main documentation Web page`_ includes links to documentation for 146 138 all previous versions. django/branches/newforms-admin/docs/modpython.txt
r4940 r4962 58 58 .. caution:: 59 59 60 I s you are using Windows, remember that the path will contain backslashes.60 If you're using Windows, remember that the path will contain backslashes. 61 61 This string is passed through Python's string parser twice, so you need to 62 62 escape each backslash **twice**:: … … 64 64 PythonPath "['c:\\\\path\\\\to\\\\project'] + sys.path" 65 65 66 oruse raw strings::66 Or, use raw strings:: 67 67 68 68 PythonPath "[r'c:\\path\\to\\project'] + sys.path" 69 70 69 71 70 You can also add directives such as ``PythonAutoReload Off`` for performance. … … 162 161 particular part of the site:: 163 162 164 <Location "/media /">163 <Location "/media"> 165 164 SetHandler None 166 165 </Location> … … 179 178 </Location> 180 179 181 <Location " media">180 <Location "/media"> 182 181 SetHandler None 183 182 </Location> django/branches/newforms-admin/docs/request_response.txt
r4940 r4962 484 484 called ``404.html`` and located in the top level of your template tree. 485 485 486 Customi ng error views487 --------------------- 486 Customizing error views 487 ----------------------- 488 488 489 489 The 404 (page not found) view django/branches/newforms-admin/tests/modeltests/model_forms/models.py
r4824 r4962 160 160 <option value="2">Bob Woodward</option> 161 161 </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> 163 163 <tr><th>Categories:</th><td><select multiple="multiple" name="categories"> 164 164 <option value="1">Entertainment</option> … … 200 200 <option value="2">Bob Woodward</option> 201 201 </select></li> 202 <li>Article: <textarea name="article">Hello.</textarea></li>202 <li>Article: <textarea rows="10" cols="40" name="article">Hello.</textarea></li> 203 203 <li>Categories: <select multiple="multiple" name="categories"> 204 204 <option value="1">Entertainment</option> … … 232 232 <option value="2">Bob Woodward</option> 233 233 </select></li> 234 <li>Article: <textarea name="article">Hello.</textarea></li>234 <li>Article: <textarea rows="10" cols="40" name="article">Hello.</textarea></li> 235 235 <li>Categories: <select multiple="multiple" name="categories"> 236 236 <option value="1" selected="selected">Entertainment</option> … … 310 310 <option value="2">Bob Woodward</option> 311 311 </select></li> 312 <li>Article: <textarea name="article"></textarea></li>312 <li>Article: <textarea rows="10" cols="40" name="article"></textarea></li> 313 313 <li>Categories: <select multiple="multiple" name="categories"> 314 314 <option value="1">Entertainment</option> … … 329 329 <option value="3">Carl Bernstein</option> 330 330 </select></li> 331 <li>Article: <textarea name="article"></textarea></li>331 <li>Article: <textarea rows="10" cols="40" name="article"></textarea></li> 332 332 <li>Categories: <select multiple="multiple" name="categories"> 333 333 <option value="1">Entertainment</option> django/branches/newforms-admin/tests/regressiontests/forms/localflavor.py
r4940 r4962 7 7 USZipCodeField validates that the data is either a five-digit U.S. zip code or 8 8 a zip+4. 9 >>> from django.contrib.localflavor.us a.forms import USZipCodeField9 >>> from django.contrib.localflavor.us.forms import USZipCodeField 10 10 >>> f = USZipCodeField() 11 11 >>> f.clean('60606') … … 68 68 USPhoneNumberField validates that the data is a valid U.S. phone number, 69 69 including the area code. It's normalized to XXX-XXX-XXXX format. 70 >>> from django.contrib.localflavor.us a.forms import USPhoneNumberField70 >>> from django.contrib.localflavor.us.forms import USPhoneNumberField 71 71 >>> f = USPhoneNumberField() 72 72 >>> f.clean('312-555-1212') … … 137 137 USStateField validates that the data is either an abbreviation or name of a 138 138 U.S. state. 139 >>> from django.contrib.localflavor.us a.forms import USStateField139 >>> from django.contrib.localflavor.us.forms import USStateField 140 140 >>> f = USStateField() 141 141 >>> f.clean('il') … … 182 182 USStateSelect is a Select widget that uses a list of U.S. states/territories 183 183 as its choices. 184 >>> from django.contrib.localflavor.us a.forms import USStateSelect184 >>> from django.contrib.localflavor.us.forms import USStateSelect 185 185 >>> w = USStateSelect() 186 186 >>> print w.render('state', 'IL') … … 248 248 249 249 # USSocialSecurityNumberField ################################################# 250 >>> from django.contrib.localflavor.us a.forms import USSocialSecurityNumberField250 >>> from django.contrib.localflavor.us.forms import USSocialSecurityNumberField 251 251 >>> f = USSocialSecurityNumberField() 252 252 >>> f.clean('987-65-4330') … … 883 883 ... 884 884 ValidationError: [u'Enter a valid German identity card number in XXXXXXXXXXX-XXXXXXX-XXXXXXX-X format.'] 885 886 ## AUPostCodeField ########################################################## 887 888 A 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') 893 u'1234' 894 >>> f.clean('2000') 895 u'2000' 896 >>> f.clean('abcd') 897 Traceback (most recent call last): 898 ... 899 ValidationError: [u'Enter a 4 digit post code.'] 900 >>> f.clean('20001') 901 Traceback (most recent call last): 902 ... 903 ValidationError: [u'Enter a 4 digit post code.'] 904 >>> f.clean(None) 905 Traceback (most recent call last): 906 ... 907 ValidationError: [u'This field is required.'] 908 >>> f.clean('') 909 Traceback (most recent call last): 910 ... 911 ValidationError: [u'This field is required.'] 912 913 >>> f = AUPostCodeField(required=False) 914 >>> f.clean('1234') 915 u'1234' 916 >>> f.clean('2000') 917 u'2000' 918 >>> f.clean('abcd') 919 Traceback (most recent call last): 920 ... 921 ValidationError: [u'Enter a 4 digit post code.'] 922 >>> f.clean('20001') 923 Traceback (most recent call last): 924 ... 925 ValidationError: [u'Enter a 4 digit post code.'] 926 >>> f.clean(None) 927 u'' 928 >>> f.clean('') 929 u'' 930 931 ## AUPhoneNumberField ######################################################## 932 933 A field that accepts a 10 digit Australian phone number. 934 llows spaces and parentheses around area code. 935 936 >>> from django.contrib.localflavor.au.forms import AUPhoneNumberField 937 >>> f = AUPhoneNumberField() 938 >>> f.clean('1234567890') 939 u'1234567890' 940 >>> f.clean('0213456789') 941 u'0213456789' 942 >>> f.clean('02 13 45 67 89') 943 u'0213456789' 944 >>> f.clean('(02) 1345 6789') 945 u'0213456789' 946 >>> f.clean('(02) 1345-6789') 947 u'0213456789' 948 >>> f.clean('(02)1345-6789') 949 u'0213456789' 950 >>> f.clean('0408 123 456') 951 u'0408123456' 952 >>> f.clean('123') 953 Traceback (most recent call last): 954 ... 955 ValidationError: [u'Phone numbers must contain 10 digits.'] 956 >>> f.clean('1800DJANGO') 957 Traceback (most recent call last): 958 ... 959 ValidationError: [u'Phone numbers must contain 10 digits.'] 960 >>> f.clean(None) 961 Traceback (most recent call last): 962 ... 963 ValidationError: [u'This field is required.'] 964 >>> f.clean('') 965 Traceback (most recent call last): 966 ... 967 ValidationError: [u'This field is required.'] 968 969 >>> f = AUPhoneNumberField(required=False) 970 >>> f.clean('1234567890') 971 u'1234567890' 972 >>> f.clean('0213456789') 973 u'0213456789' 974 >>> f.clean('02 13 45 67 89') 975 u'0213456789' 976 >>> f.clean('(02) 1345 6789') 977 u'0213456789' 978 >>> f.clean('(02) 1345-6789') 979 u'0213456789' 980 >>> f.clean('(02)1345-6789') 981 u'0213456789' 982 >>> f.clean('0408 123 456') 983 u'0408123456' 984 >>> f.clean('123') 985 Traceback (most recent call last): 986 ... 987 ValidationError: [u'Phone numbers must contain 10 digits.'] 988 >>> f.clean('1800DJANGO') 989 Traceback (most recent call last): 990 ... 991 ValidationError: [u'Phone numbers must contain 10 digits.'] 992 >>> f.clean(None) 993 u'' 994 >>> f.clean('') 995 u'' 996 997 ## AUStateSelect ############################################################# 998 999 AUStateSelect is a Select widget that uses a list of Australian 1000 states/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> 885 1015 """ django/branches/newforms-admin/tests/regressiontests/forms/tests.py
r4953 r4962 195 195 >>> w = Textarea() 196 196 >>> w.render('msg', '') 197 u'<textarea name="msg"></textarea>'197 u'<textarea rows="10" cols="40" name="msg"></textarea>' 198 198 >>> w.render('msg', None) 199 u'<textarea name="msg"></textarea>'199 u'<textarea rows="10" cols="40" name="msg"></textarea>' 200 200 >>> w.render('msg', 'value') 201 u'<textarea name="msg">value</textarea>'201 u'<textarea rows="10" cols="40" name="msg">value</textarea>' 202 202 >>> w.render('msg', 'some "quoted" & ampersanded value') 203 u'<textarea name="msg">some "quoted" & ampersanded value</textarea>'204 >>> w.render('msg', 'value', attrs={'class': 'pretty' })205 u'<textarea name="msg" class="pretty">value</textarea>'203 u'<textarea rows="10" cols="40" name="msg">some "quoted" & ampersanded value</textarea>' 204 >>> w.render('msg', 'value', attrs={'class': 'pretty', 'rows': 20}) 205 u'<textarea class="pretty" rows="20" cols="40" name="msg">value</textarea>' 206 206 207 207 You can also pass 'attrs' to the constructor: 208 208 >>> w = Textarea(attrs={'class': 'pretty'}) 209 209 >>> w.render('msg', '') 210 u'<textarea class="pretty" name="msg"></textarea>'210 u'<textarea rows="10" cols="40" name="msg" class="pretty"></textarea>' 211 211 >>> w.render('msg', 'example') 212 u'<textarea class="pretty" name="msg">example</textarea>'212 u'<textarea rows="10" cols="40" name="msg" class="pretty">example</textarea>' 213 213 214 214 'attrs' passed to render() get precedence over those passed to the constructor: 215 215 >>> w = Textarea(attrs={'class': 'pretty'}) 216 216 >>> w.render('msg', '', attrs={'class': 'special'}) 217 u'<textarea class="special" name="msg"></textarea>'217 u'<textarea rows="10" cols="40" name="msg" class="special"></textarea>' 218 218 219 219 >>> w.render('msg', 'ŠĐĆŽćžšđ', attrs={'class': 'fun'}) 220 u'<textarea class="fun" name="msg">\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111</textarea>'220 u'<textarea rows="10" cols="40" name="msg" class="fun">\u0160\u0110\u0106\u017d\u0107\u017e\u0161\u0111</textarea>' 221 221 222 222 # CheckboxInput Widget ######################################################## … … 1968 1968 <input type="text" name="subject" /> 1969 1969 >>> print f['message'] 1970 <textarea name="message"></textarea>1970 <textarea rows="10" cols="40" name="message"></textarea> 1971 1971 1972 1972 as_textarea(), as_text() and as_hidden() are shortcuts for changing the output 1973 1973 widget type: 1974 1974 >>> f['subject'].as_textarea() 1975 u'<textarea name="subject"></textarea>'1975 u'<textarea rows="10" cols="40" name="subject"></textarea>' 1976 1976 >>> f['message'].as_text() 1977 1977 u'<input type="text" name="message" />' … … 1993 1993 >>> f = ContactForm({'subject': 'Hello', 'message': 'I love you.'}, auto_id=False) 1994 1994 >>> f['subject'].as_textarea() 1995 u'<textarea name="subject">Hello</textarea>'1995 u'<textarea rows="10" cols="40" name="subject">Hello</textarea>' 1996 1996 >>> f['message'].as_text() 1997 1997 u'<input type="text" name="message" value="I love you." />'
