Changeset 6014
- Timestamp:
- 08/25/07 18:31:05 (1 year ago)
- Files:
-
- django/branches/newforms-admin (modified) (1 prop)
- django/branches/newforms-admin/AUTHORS (modified) (5 diffs)
- django/branches/newforms-admin/django/contrib/auth/views.py (modified) (1 diff)
- django/branches/newforms-admin/django/contrib/humanize/templatetags/humanize.py (modified) (2 diffs)
- django/branches/newforms-admin/django/core/management/commands/flush.py (modified) (1 diff)
- django/branches/newforms-admin/django/core/management/commands/runserver.py (modified) (2 diffs)
- django/branches/newforms-admin/django/core/management/commands/sqlflush.py (modified) (1 diff)
- django/branches/newforms-admin/django/core/management/sql.py (modified) (2 diffs)
- django/branches/newforms-admin/django/db/backends/dummy/base.py (modified) (2 diffs)
- django/branches/newforms-admin/django/db/backends/oracle/base.py (modified) (1 diff)
- django/branches/newforms-admin/django/db/backends/postgresql/base.py (modified) (1 diff)
- django/branches/newforms-admin/django/db/backends/postgresql/operations.py (modified) (2 diffs)
- django/branches/newforms-admin/django/db/backends/postgresql_psycopg2/base.py (modified) (1 diff)
- django/branches/newforms-admin/django/__init__.py (modified) (1 diff)
- django/branches/newforms-admin/django/utils/version.py (copied) (copied from django/trunk/django/utils/version.py)
- django/branches/newforms-admin/docs/add_ons.txt (modified) (1 diff)
- django/branches/newforms-admin/docs/db-api.txt (modified) (1 diff)
- django/branches/newforms-admin/docs/django-admin.txt (modified) (4 diffs)
- django/branches/newforms-admin/docs/faq.txt (modified) (1 diff)
- django/branches/newforms-admin/docs/model-api.txt (modified) (1 diff)
- django/branches/newforms-admin/docs/newforms.txt (modified) (11 diffs)
- django/branches/newforms-admin/docs/settings.txt (modified) (1 diff)
- django/branches/newforms-admin/docs/testing.txt (modified) (1 diff)
- django/branches/newforms-admin/docs/tutorial01.txt (modified) (2 diffs)
- django/branches/newforms-admin/tests/regressiontests/humanize/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-5983 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-6013
django/branches/newforms-admin/AUTHORS
r5996 r6014 96 96 deric@monowerks.com 97 97 Max Derkachev <mderk@yandex.ru> 98 Sander Dijkhuis <sander.dijkhuis@gmail.com> 98 99 Jordan Dimov <s3x3y1@gmail.com> 99 100 dne@mayonnaise.net … … 138 139 Joel Heenan <joelh-django@planetjoel.com> 139 140 hipertracker@gmail.com 141 Deryck Hodge <http://www.devurandom.org/> 140 142 Brett Hoerner <bretthoerner@bretthoerner.com> 141 143 Ian Holsman <http://feh.holsman.net/> … … 205 207 Reza Mohammadi <reza@zeerak.ir> 206 208 Aljosa Mohorovic <aljosa.mohorovic@gmail.com> 209 Ramiro Morales <rm0@gmx.net> 207 210 Eric Moritz <http://eric.themoritzfamily.com/> 208 211 mrmachine <real.human@mrmachine.net> … … 214 217 Sam Newman <http://www.magpiebrain.com/> 215 218 Neal Norwitz <nnorwitz@google.com> 219 Todd O'Bryan <toddobryan@mac.com> 216 220 oggie rob <oz.robharvey@gmail.com> 217 221 Jay Parlar <parlar@gmail.com> … … 229 233 polpak@yahoo.com 230 234 Matthias Pronk <django@masida.nl> 235 Jyrki Pulliainen <jyrki.pulliainen@gmail.com> 231 236 Johann Queuniet <johann.queuniet@adh.naellia.eu> 232 237 J. Rademaker 233 238 Michael Radziej <mir@noris.de> 234 Ramiro Morales <rm0@gmx.net>235 239 Massimiliano Ravelli <massimiliano.ravelli@gmail.com> 236 240 Brian Ray <http://brianray.chipy.org/> django/branches/newforms-admin/django/contrib/auth/views.py
r5918 r6014 18 18 if not errors: 19 19 # Light security check -- make sure redirect_to isn't garbage. 20 if not redirect_to or ' ://' in redirect_to or ' ' in redirect_to:20 if not redirect_to or '//' in redirect_to or ' ' in redirect_to: 21 21 from django.conf import settings 22 22 redirect_to = settings.LOGIN_REDIRECT_URL django/branches/newforms-admin/django/contrib/humanize/templatetags/humanize.py
r5627 r6014 2 2 from django.utils.encoding import force_unicode 3 3 from django import template 4 from django.template import defaultfilters 5 from django.conf import settings 6 from datetime import date, timedelta 4 7 import re 5 8 … … 68 71 return (_('one'), _('two'), _('three'), _('four'), _('five'), _('six'), _('seven'), _('eight'), _('nine'))[value-1] 69 72 register.filter(apnumber) 73 74 def naturalday(value, arg=None): 75 """ 76 For date values that are tomorrow, today or yesterday compared to 77 present day returns representing string. Otherwise, returns a string 78 formatted according to settings.DATE_FORMAT. 79 """ 80 try: 81 value = date(value.year, value.month, value.day) 82 except AttributeError: 83 # Passed value wasn't a date object 84 return value 85 except ValueError: 86 # Date arguments out of range 87 return value 88 delta = value - date.today() 89 if delta.days == 0: 90 return _(u'today') 91 elif delta.days == 1: 92 return _(u'tomorrow') 93 elif delta.days == -1: 94 return _(u'yesterday') 95 return defaultfilters.date(value, arg) 96 register.filter(naturalday) django/branches/newforms-admin/django/core/management/commands/flush.py
r5918 r6014 25 25 pass 26 26 27 sql_list = sql_flush(self.style )27 sql_list = sql_flush(self.style, only_django=True) 28 28 29 29 if interactive: django/branches/newforms-admin/django/core/management/commands/runserver.py
r5918 r6014 31 31 32 32 use_reloader = options.get('use_reloader', True) 33 admin_media_ dir = options.get('admin_media_dir', '')33 admin_media_path = options.get('admin_media_path', '') 34 34 shutdown_message = options.get('shutdown_message', '') 35 35 quit_command = (sys.platform == 'win32') and 'CTRL-BREAK' or 'CONTROL-C' … … 43 43 print "Quit the server with %s." % quit_command 44 44 try: 45 path = admin_media_ diror django.__path__[0] + '/contrib/admin/media'45 path = admin_media_path or django.__path__[0] + '/contrib/admin/media' 46 46 handler = AdminMediaHandler(WSGIHandler(), path) 47 47 run(addr, int(port), handler) django/branches/newforms-admin/django/core/management/commands/sqlflush.py
r5918 r6014 8 8 def handle_noargs(self, **options): 9 9 from django.core.management.sql import sql_flush 10 return '\n'.join(sql_flush(self.style ))10 return '\n'.join(sql_flush(self.style, only_django=True)) django/branches/newforms-admin/django/core/management/sql.py
r5984 r6014 13 13 cursor = connection.cursor() 14 14 return get_introspection_module().get_table_list(cursor) 15 16 def django_table_list(only_existing=False): 17 """ 18 Returns a list of all table names that have associated Django models and 19 are in INSTALLED_APPS. 20 21 If only_existing is True, the resulting list will only include the tables 22 that actually exist in the database. 23 """ 24 from django.db import models 25 tables = [] 26 for app in models.get_apps(): 27 for model in models.get_models(app): 28 tables.append(model._meta.db_table) 29 tables.extend([f.m2m_db_table() for f in model._meta.many_to_many]) 30 if only_existing: 31 existing = table_list() 32 tables = [t for t in tables if t in existing] 33 return tables 15 34 16 35 def installed_models(table_list): … … 182 201 return sql_delete(app, style) + sql_all(app, style) 183 202 184 def sql_flush(style): 185 "Returns a list of the SQL statements used to flush the database." 203 def sql_flush(style, only_django=False): 204 """ 205 Returns a list of the SQL statements used to flush the database. 206 207 If only_django is True, then only table names that have associated Django 208 models and are in INSTALLED_APPS will be included. 209 """ 186 210 from django.db import connection 187 statements = connection.ops.sql_flush(style, table_list(), sequence_list()) 211 if only_django: 212 tables = django_table_list() 213 else: 214 tables = table_list() 215 statements = connection.ops.sql_flush(style, tables, sequence_list()) 188 216 return statements 189 217 django/branches/newforms-admin/django/db/backends/dummy/base.py
r5984 r6014 9 9 10 10 from django.core.exceptions import ImproperlyConfigured 11 from django.db.backends import BaseDatabaseFeatures, BaseDatabaseOperations 11 12 12 13 def complain(*args, **kwargs): … … 22 23 pass 23 24 24 class ComplainOnGetattr(object): 25 def __getattr__(self, *args, **kwargs): 26 complain() 25 class DatabaseOperations(BaseDatabaseOperations): 26 quote_name = complain 27 27 28 28 class DatabaseWrapper(object): 29 features = ComplainOnGetattr()30 ops = ComplainOnGetattr()29 features = BaseDatabaseFeatures() 30 ops = DatabaseOperations() 31 31 operators = {} 32 32 cursor = complain django/branches/newforms-admin/django/db/backends/oracle/base.py
r5984 r6014 71 71 72 72 def field_cast_sql(self, db_type): 73 if db_type .endswith('LOB'):73 if db_type and db_type.endswith('LOB'): 74 74 return "DBMS_LOB.SUBSTR(%s)" 75 75 else: django/branches/newforms-admin/django/db/backends/postgresql/base.py
r5984 r6014 103 103 cursor.execute("SET client_encoding to 'UNICODE'") 104 104 cursor = UnicodeCursorWrapper(cursor, 'utf-8') 105 if self.ops.postgres_version is None:106 cursor.execute("SELECT version()")107 self.ops.postgres_version = [int(val) for val in cursor.fetchone()[0].split()[1].split('.')]108 105 return cursor 109 106 django/branches/newforms-admin/django/db/backends/postgresql/operations.py
r5984 r6014 5 5 6 6 class DatabaseOperations(BaseDatabaseOperations): 7 def __init__(self, postgres_version=None): 8 self.postgres_version = postgres_version 7 def __init__(self): 8 self._postgres_version = None 9 10 def _get_postgres_version(self): 11 if self._postgres_version is None: 12 from django.db import connection 13 cursor = connection.cursor() 14 cursor.execute("SELECT version()") 15 self._postgres_version = [int(val) for val in cursor.fetchone()[0].split()[1].split('.')] 16 return self._postgres_version 17 postgres_version = property(_get_postgres_version) 9 18 10 19 def date_extract_sql(self, lookup_type, field_name): … … 53 62 table_name = sequence_info['table'] 54 63 column_name = sequence_info['column'] 55 if column_name and len(column_name)>0: 56 # sequence name in this case will be <table>_<column>_seq 57 sql.append("%s %s %s %s %s %s;" % \ 58 (style.SQL_KEYWORD('ALTER'), 59 style.SQL_KEYWORD('SEQUENCE'), 60 style.SQL_FIELD(self.quote_name('%s_%s_seq' % (table_name, column_name))), 61 style.SQL_KEYWORD('RESTART'), 62 style.SQL_KEYWORD('WITH'), 63 style.SQL_FIELD('1') 64 ) 65 ) 64 if column_name and len(column_name) > 0: 65 sequence_name = '%s_%s_seq' % (table_name, column_name) 66 66 else: 67 # sequence name in this case will be <table>_id_seq 68 sql.append("%s %s %s %s %s %s;" % \ 69 (style.SQL_KEYWORD('ALTER'), 70 style.SQL_KEYWORD('SEQUENCE'), 71 style.SQL_FIELD(self.quote_name('%s_id_seq' % table_name)), 72 style.SQL_KEYWORD('RESTART'), 73 style.SQL_KEYWORD('WITH'), 74 style.SQL_FIELD('1') 75 ) 76 ) 67 sequence_name = '%s_id_seq' % table_name 68 sql.append("%s setval('%s', 1, false);" % \ 69 (style.SQL_KEYWORD('SELECT'), 70 style.SQL_FIELD(self.quote_name(sequence_name))) 71 ) 77 72 return sql 78 73 else: django/branches/newforms-admin/django/db/backends/postgresql_psycopg2/base.py
r5984 r6014 65 65 if set_tz: 66 66 cursor.execute("SET TIME ZONE %s", [settings.TIME_ZONE]) 67 if self.ops.postgres_version is None:68 cursor.execute("SELECT version()")69 self.ops.postgres_version = [int(val) for val in cursor.fetchone()[0].split()[1].split('.')]70 67 return cursor django/branches/newforms-admin/django/__init__.py
r5475 r6014 5 5 v = '.'.join([str(i) for i in VERSION[:-1]]) 6 6 if VERSION[-1]: 7 v += '-' + VERSION[-1] 7 from django.utils.version import get_svn_revision 8 v = '%s-%s-%s' % (v, VERSION[-1], get_svn_revision()) 8 9 return v django/branches/newforms-admin/docs/add_ons.txt
r5828 r6014 139 139 You can pass in either an integer or a string representation of an integer. 140 140 141 naturalday 142 ---------- 143 144 **New in Django development version** 145 146 For dates that are the current day or within one day, return "today", 147 "tomorrow" or "yesterday", as appropriate. Otherwise, format the date using 148 the passed in format string. 149 150 **Argument:** Date formatting string as described in default tag now_. 151 152 .. _now: ../templates/#now 153 154 Examples (when 'today' is 17 Feb 2007): 155 156 * ``16 Feb 2007`` becomes ``yesterday``. 157 * ``17 Feb 2007`` becomes ``today``. 158 * ``18 Feb 2007`` becomes ``tomorrow``. 159 * Any other day is formatted according to given argument or the 160 `DATE_FORMAT`_ setting if no argument is given. 161 162 .. _DATE_FORMAT: ../settings/#date_format 163 141 164 flatpages 142 165 ========= django/branches/newforms-admin/docs/db-api.txt
r5828 r6014 208 208 The ``save()`` method has no return value. 209 209 210 Updating ``ForeignKey`` fields works exactly the same way; simply assign an 211 object of the right type to the field in question:: 210 Saving ForeignKey and ManyToManyField fields 211 -------------------------------------------- 212 213 Updating ``ForeignKey`` fields works exactly the same way as saving a normal 214 field; simply assign an object of the right type to the field in question:: 215 216 cheese_blog = Blog.objects.get(name="Cheddar Talk") 217 entry.blog = cheese_blog 218 entry.save() 219 220 Updating a ``ManyToManyField`` works a little differently; use the ``add()`` 221 method on the field to add a record to the relation:: 212 222 213 223 joe = Author.objects.create(name="Joe") 214 entry.author = joe 215 entry.save() 216 217 Django will complain if you try to assign an object of the wrong type. 224 entry.authors.add(joe) 225 226 Django will complain if you try to assign or add an object of the wrong type. 218 227 219 228 How Django knows to UPDATE vs. INSERT django/branches/newforms-admin/docs/django-admin.txt
r5918 r6014 124 124 post-synchronization handlers will be re-executed, and the ``initial_data`` 125 125 fixture will be re-installed. 126 127 The behavior of this command has changed in the Django development version. 128 Previously, this command cleared *every* table in the database, including any 129 table that Django didn't know about (i.e., tables that didn't have associated 130 models and/or weren't in ``INSTALLED_APPS``). Now, the command only clears 131 tables that are represented by Django models and are activated in 132 ``INSTALLED_APPS``. 126 133 127 134 inspectdb … … 241 248 runfcgi [options] 242 249 ----------------- 250 243 251 Starts a set of FastCGI processes suitable for use with any web server 244 252 which supports the FastCGI protocol. See the `FastCGI deployment … … 338 346 339 347 sqlclear [appname appname ...] 340 ------------------------------ --------348 ------------------------------ 341 349 342 350 Prints the DROP TABLE SQL statements for the given appnames. … … 361 369 Note that the order in which the SQL files are processed is undefined. 362 370 371 sqlflush 372 -------- 373 374 Prints the SQL statements that would be executed for the `flush`_ command. 375 363 376 sqlindexes [appname appname ...] 364 -------------------------------- --------377 -------------------------------- 365 378 366 379 Prints the CREATE INDEX SQL statements for the given appnames. 367 380 368 381 sqlreset [appname appname ...] 382 ------------------------------ 383 384 Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given appnames. 385 386 sqlsequencereset [appname appname ...] 369 387 -------------------------------------- 370 371 Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given appnames.372 373 sqlsequencereset [appname appname ...]374 ----------------------------------------------375 388 376 389 Prints the SQL statements for resetting sequences for the given django/branches/newforms-admin/docs/faq.txt
r5828 r6014 205 205 spend a lot of energy creating screencasts yet, because Django APIs will shift. 206 206 207 In the meantime, though, check out this `unofficial Django screencast`_.208 209 .. _unofficial Django screencast: http://www.throwingbeans.org/django_screencasts.html210 211 207 Is Django a content-management-system (CMS)? 212 208 -------------------------------------------- django/branches/newforms-admin/docs/model-api.txt
r5918 r6014 345 345 ~~~~~~~~~~~~~~ 346 346 347 Like ` `FileField``, but validates that the uploaded object is a valid347 Like `FileField`_, but validates that the uploaded object is a valid 348 348 image. Has two extra optional arguments, ``height_field`` and 349 349 ``width_field``, which, if set, will be auto-populated with the height and django/branches/newforms-admin/docs/newforms.txt
r5986 r6014 1463 1463 ``CheckboxInput`` ``<input type='checkbox' ...`` 1464 1464 ``Select`` ``<select><option ...`` 1465 ``NullBooleanSelect`` Select widget with options 'Unknown', 1465 ``NullBooleanSelect`` Select widget with options 'Unknown', 1466 1466 'Yes' and 'No' 1467 1467 ``SelectMultiple`` ``<select multiple='multiple'><option ...`` 1468 ``RadioSelect`` ``<ul><li><input type='radio' ...`` 1468 ``RadioSelect`` ``<ul><li><input type='radio' ...`` 1469 1469 ``CheckboxSelectMultiple`` ``<ul><li><input type='checkbox' ...`` 1470 1470 ``MultiWidget`` Wrapper around multiple other widgets … … 1477 1477 1478 1478 Whenever you specify a field on a form, Django will use a default widget 1479 that is appropriate to the type of data that is to be displayed. To find 1479 that is appropriate to the type of data that is to be displayed. To find 1480 1480 which widget is used on which field, see the documentation for the 1481 1481 built-in Field classes. 1482 1482 1483 However, if you want to use a different widget for a field, you can - 1483 However, if you want to use a different widget for a field, you can - 1484 1484 just use the 'widget' argument on the field definition. For example:: 1485 1485 … … 1488 1488 url = forms.URLField() 1489 1489 comment = forms.CharField(widget=forms.Textarea) 1490 1491 This would specify a form with a comment that uses a larger Textarea widget, 1490 1491 This would specify a form with a comment that uses a larger Textarea widget, 1492 1492 rather than the default TextInput widget. 1493 1493 … … 1500 1500 on your web page. 1501 1501 1502 If you want to make one widget look different to another, you need to 1503 specify additional attributes for each widget. When you specify a 1502 If you want to make one widget look different to another, you need to 1503 specify additional attributes for each widget. When you specify a 1504 1504 widget, you can provide a list of attributes that will be added to the 1505 1505 rendered HTML for the widget. … … 1523 1523 1524 1524 On a real web page, you probably don't want every widget to look the same. You 1525 might want a larger input element for the comment, and you might want the 1526 'name' widget to have some special CSS class. To do this, you specify a 1527 custom widget for your fields, and specify some attributes to use 1525 might want a larger input element for the comment, and you might want the 1526 'name' widget to have some special CSS class. To do this, you specify a 1527 custom widget for your fields, and specify some attributes to use 1528 1528 when rendering those widgets:: 1529 1529 1530 1530 class CommentForm(forms.Form): 1531 name = forms.CharField( 1531 name = forms.CharField( 1532 1532 widget=forms.TextInput(attrs={'class':'special'})) 1533 1533 url = forms.URLField() … … 1547 1547 1548 1548 When you start to write a lot of forms, you will probably find that you will 1549 reuse certain sets of widget attributes over and over again. Rather than 1550 repeat these attribute definitions every time you need them, Django allows 1549 reuse certain sets of widget attributes over and over again. Rather than 1550 repeat these attribute definitions every time you need them, Django allows 1551 1551 you to capture those definitions as a custom widget. 1552 1552 1553 1553 For example, if you find that you are including a lot of comment fields on forms, 1554 you could capture the idea of a ``TextInput`` with a specific ``size`` attribute 1554 you could capture the idea of a ``TextInput`` with a specific ``size`` attribute 1555 1555 as a custom extension to the ``TextInput`` widget:: 1556 1556 … … 1558 1558 def __init__(self, *args, **kwargs): 1559 1559 kwargs.setdefault('attrs',{}).update({'size': '40'}) 1560 super( forms.TextInput, self).__init__(*args, **kwargs)1561 1560 super(CommentWidget, self).__init__(*args, **kwargs) 1561 1562 1562 Then you can use this widget in your forms:: 1563 1563 … … 1567 1567 comment = forms.CharField(widget=CommentWidget) 1568 1568 1569 You can even customize your custom widget, in the same way as you would 1570 any other widget. Adding a once-off class to your ``CommentWidget`` is as 1569 You can even customize your custom widget, in the same way as you would 1570 any other widget. Adding a once-off class to your ``CommentWidget`` is as 1571 1571 simple as adding an attribute definition:: 1572 1572 … … 1583 1583 class CommentInput(forms.CharField): 1584 1584 widget = CommentWidget 1585 1585 1586 1586 You can then use this field whenever you have a form that requires a comment:: 1587 1587 … … 1590 1590 url = forms.URLField() 1591 1591 comment = CommentInput() 1592 1592 1593 1593 Generating forms for models 1594 1594 =========================== … … 1935 1935 arguments that behave the same way as they do for ``form_for_model()``. 1936 1936 1937 Let's modify the earlier `contact form`_ view example a little bit. Suppose we 1938 have a ``Message`` model that holds each contact submission. Something like:: 1939 1940 class Message(models.Model): 1941 subject = models.CharField(max_length=100) 1942 message = models.TextField() 1943 sender = models.EmailField() 1944 cc_myself = models.BooleanField() 1945 1946 You could use this model to create a form (using ``form_for_model()``). You 1947 could also use existing ``Message`` instances to create a form for editing 1948 messages. The earlier_ view can be changed slightly to accept the ``id`` value 1949 of an existing ``Message`` and present it for editing:: 1950 1951 def contact_edit(request, msg_id): 1952 # Create the form from the message id. 1953 message = get_object_or_404(Message, id=msg_id) 1954 ContactForm = form_for_instance(message) 1955 1956 if request.method == 'POST': 1957 form = ContactForm(request.POST) 1958 if form.is_valid(): 1959 form.save() 1960 return HttpResponseRedirect('/url/on_success/') 1961 else: 1962 form = ContactForm() 1963 return render_to_response('contact.html', {'form': form}) 1964 1965 Aside from how we create the ``ContactForm`` class here, the main point to 1966 note is that the form display in the ``GET`` branch of the function 1967 will use the values from the ``message`` instance as initial values for the 1968 form field. 1969 1970 .. _contact form: `Simple view example`_ 1971 .. _earlier: `Simple view example`_ 1972 1937 1973 When should you use ``form_for_model()`` and ``form_for_instance()``? 1938 1974 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ django/branches/newforms-admin/docs/settings.txt
r5627 r6014 1102 1102 ---------- 1103 1103 1104 When ``DEBUG`` is ``False`` and your ``MIDDLEWARE_CLASSES`` setting includes 1105 ``CommonMiddleware``, Django will e-mail the users listed in the ``MANAGERS`` 1106 setting whenever your code raises a 404 and the request has a referer. 1107 (It doesn't bother to e-mail for 404s that don't have a referer.) 1104 When ``DEBUG`` is ``False``, ``SEND_BROKEN_LINK_EMAILS`` is ``True`` and your 1105 ``MIDDLEWARE_CLASSES`` setting includes ``CommonMiddleware``, Django will 1106 e-mail the users listed in the ``MANAGERS`` setting whenever your code raises 1107 a 404 and the request has a referer. (It doesn't bother to e-mail for 404s 1108 that don't have a referer.) 1108 1109 1109 1110 You can tell Django to stop reporting particular 404s by tweaking the django/branches/newforms-admin/docs/testing.txt
r5918 r6014 474 474 475 475 >>> c = Client() 476 >>> c. get('/login/', {'name': 'fred', 'passwd': 'secret'})476 >>> c.post('/login/', {'name': 'fred', 'passwd': 'secret'}) 477 477 478 478 ...will result in the evaluation of a POST request to this URL:: django/branches/newforms-admin/docs/tutorial01.txt
r5918 r6014 259 259 choice = models.CharField(max_length=200) 260 260 votes = models.IntegerField() 261 262 .. adminition:: Errors about ``max_length`` 263 264 If Django gives you an error message saying that ``max_length`` is 265 not a valid argument, you're most likely using an old version of 266 Django. (This version of the tutorial is written for the latest 267 development version of Django.) If you're using a Subversion checkout 268 of Django's development version (see `the installation docs`_ for 269 more information), you shouldn't have any problems. 270 271 If you want to stick with an older version of Django, you'll want to 272 switch to `the Django 0.96 tutorial`_, because this tutorial covers 273 several features that only exist in the Django development version. 274 275 .. _the installation docs: ../install/ 276 .. _the Django 0.96 tutorial: ../0.96/tutorial01/ 261 277 262 278 The code is straightforward. Each model is represented by a class that … … 488 504 return self.choice 489 505 506 .. admonition:: If ``__unicode__()`` doesn't seem to work 507 508 If you add the ``__unicode__()`` method to your models and don't 509 see any change in how they're represented, you're most likely using 510 an old version of Django. (This version of the tutorial is written 511 for the latest development version of Django.) If you're using a 512 Subversion checkout of of Django's development version (see `the 513 installation docs`_ for more information), you shouldn't have any 514 problems. 515 516 If you want to stick with an older version of Django, you'll want to 517 switch to `the Django 0.96 tutorial`_, because this tutorial covers 518 several features that only exist in the Django development version. 519 520 .. _the installation docs: ../install/ 521 .. _the Django 0.96 tutorial: ../0.96/tutorial01/ 522 490 523 It's important to add ``__unicode__()`` methods to your models, not only for 491 524 your own sanity when dealing with the interactive prompt, but also because django/branches/newforms-admin/tests/regressiontests/humanize/tests.py
r5918 r6014 1 1 import unittest 2 from datetime import timedelta, date 2 3 from django.template import Template, Context, add_to_builtins 4 from django.utils.dateformat import DateFormat 5 from django.utils.translation import ugettext as _ 3 6 4 7 add_to_builtins('django.contrib.humanize.templatetags.humanize') … … 9 12 # Using max below ensures we go through both lists 10 13 # However, if the lists are not equal length, this raises an exception 11 for index in xrange( len(max(test_list,result_list))):14 for index in xrange(max(len(test_list), len(result_list))): 12 15 test_content = test_list[index] 13 16 t = Template('{{ test_content|%s }}' % method) 14 17 rendered = t.render(Context(locals())).strip() 15 18 self.assertEqual(rendered, result_list[index], 16 msg="""%s test failed, produced %s, 17 should've produced %s""" % (method, rendered, result_list[index])) 19 msg="%s test failed, produced %s, should've produced %s" % (method, rendered, result_list[index])) 18 20 19 21 def test_ordinal(self): … … 50 52 self.humanize_tester(test_list, result_list, 'apnumber') 51 53 54 def test_naturalday(self): 55 from django.template import defaultfilters 56 today = date.today() 57 yesterday = today - timedelta(days=1) 58 tomorrow = today + timedelta(days=1) 59 someday = today - timedelta(days=10) 60 notdate = u"I'm not a date value" 61 62 test_list = (today, yesterday, tomorrow, someday, notdate) 63 someday_result = defaultfilters.date(someday) 64 result_list = (_(u'today'), _(u'yesterday'), _(u'tomorrow'), 65 someday_result, u"I'm not a date value") 66 self.humanize_tester(test_list, result_list, 'naturalday') 67 52 68 if __name__ == '__main__': 53 69 unittest.main()
