Django

Code

Changeset 6014

Show
Ignore:
Timestamp:
08/25/07 18:31:05 (1 year ago)
Author:
adrian
Message:

newforms-admin: Merged to [6013]

Files:

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  
    9696    deric@monowerks.com 
    9797    Max Derkachev <mderk@yandex.ru> 
     98    Sander Dijkhuis <sander.dijkhuis@gmail.com> 
    9899    Jordan Dimov <s3x3y1@gmail.com> 
    99100    dne@mayonnaise.net 
     
    138139    Joel Heenan <joelh-django@planetjoel.com> 
    139140    hipertracker@gmail.com 
     141    Deryck Hodge <http://www.devurandom.org/> 
    140142    Brett Hoerner <bretthoerner@bretthoerner.com> 
    141143    Ian Holsman <http://feh.holsman.net/> 
     
    205207    Reza Mohammadi <reza@zeerak.ir> 
    206208    Aljosa Mohorovic <aljosa.mohorovic@gmail.com> 
     209    Ramiro Morales <rm0@gmx.net> 
    207210    Eric Moritz <http://eric.themoritzfamily.com/> 
    208211    mrmachine <real.human@mrmachine.net> 
     
    214217    Sam Newman <http://www.magpiebrain.com/> 
    215218    Neal Norwitz <nnorwitz@google.com> 
     219    Todd O'Bryan <toddobryan@mac.com> 
    216220    oggie rob <oz.robharvey@gmail.com> 
    217221    Jay Parlar <parlar@gmail.com> 
     
    229233    polpak@yahoo.com 
    230234    Matthias Pronk <django@masida.nl> 
     235    Jyrki Pulliainen <jyrki.pulliainen@gmail.com> 
    231236    Johann Queuniet <johann.queuniet@adh.naellia.eu> 
    232237    J. Rademaker 
    233238    Michael Radziej <mir@noris.de> 
    234     Ramiro Morales <rm0@gmx.net> 
    235239    Massimiliano Ravelli <massimiliano.ravelli@gmail.com> 
    236240    Brian Ray <http://brianray.chipy.org/> 
  • django/branches/newforms-admin/django/contrib/auth/views.py

    r5918 r6014  
    1818        if not errors: 
    1919            # 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: 
    2121                from django.conf import settings 
    2222                redirect_to = settings.LOGIN_REDIRECT_URL 
  • django/branches/newforms-admin/django/contrib/humanize/templatetags/humanize.py

    r5627 r6014  
    22from django.utils.encoding import force_unicode 
    33from django import template 
     4from django.template import defaultfilters 
     5from django.conf import settings 
     6from datetime import date, timedelta 
    47import re 
    58 
     
    6871    return (_('one'), _('two'), _('three'), _('four'), _('five'), _('six'), _('seven'), _('eight'), _('nine'))[value-1] 
    6972register.filter(apnumber) 
     73 
     74def 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) 
     96register.filter(naturalday) 
  • django/branches/newforms-admin/django/core/management/commands/flush.py

    r5918 r6014  
    2525                pass 
    2626 
    27         sql_list = sql_flush(self.style
     27        sql_list = sql_flush(self.style, only_django=True
    2828 
    2929        if interactive: 
  • django/branches/newforms-admin/django/core/management/commands/runserver.py

    r5918 r6014  
    3131 
    3232        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', '') 
    3434        shutdown_message = options.get('shutdown_message', '') 
    3535        quit_command = (sys.platform == 'win32') and 'CTRL-BREAK' or 'CONTROL-C' 
     
    4343            print "Quit the server with %s." % quit_command 
    4444            try: 
    45                 path = admin_media_dir or django.__path__[0] + '/contrib/admin/media' 
     45                path = admin_media_path or django.__path__[0] + '/contrib/admin/media' 
    4646                handler = AdminMediaHandler(WSGIHandler(), path) 
    4747                run(addr, int(port), handler) 
  • django/branches/newforms-admin/django/core/management/commands/sqlflush.py

    r5918 r6014  
    88    def handle_noargs(self, **options): 
    99        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  
    1313    cursor = connection.cursor() 
    1414    return get_introspection_module().get_table_list(cursor) 
     15 
     16def 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 
    1534 
    1635def installed_models(table_list): 
     
    182201    return sql_delete(app, style) + sql_all(app, style) 
    183202 
    184 def sql_flush(style): 
    185     "Returns a list of the SQL statements used to flush the database." 
     203def 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    """ 
    186210    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()) 
    188216    return statements 
    189217 
  • django/branches/newforms-admin/django/db/backends/dummy/base.py

    r5984 r6014  
    99 
    1010from django.core.exceptions import ImproperlyConfigured 
     11from django.db.backends import BaseDatabaseFeatures, BaseDatabaseOperations 
    1112 
    1213def complain(*args, **kwargs): 
     
    2223    pass 
    2324 
    24 class ComplainOnGetattr(object): 
    25     def __getattr__(self, *args, **kwargs): 
    26         complain() 
     25class DatabaseOperations(BaseDatabaseOperations): 
     26    quote_name = complain 
    2727 
    2828class DatabaseWrapper(object): 
    29     features = ComplainOnGetattr() 
    30     ops = ComplainOnGetattr() 
     29    features = BaseDatabaseFeatures() 
     30    ops = DatabaseOperations() 
    3131    operators = {} 
    3232    cursor = complain 
  • django/branches/newforms-admin/django/db/backends/oracle/base.py

    r5984 r6014  
    7171 
    7272    def field_cast_sql(self, db_type): 
    73         if db_type.endswith('LOB'): 
     73        if db_type and db_type.endswith('LOB'): 
    7474            return "DBMS_LOB.SUBSTR(%s)" 
    7575        else: 
  • django/branches/newforms-admin/django/db/backends/postgresql/base.py

    r5984 r6014  
    103103        cursor.execute("SET client_encoding to 'UNICODE'") 
    104104        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('.')] 
    108105        return cursor 
    109106 
  • django/branches/newforms-admin/django/db/backends/postgresql/operations.py

    r5984 r6014  
    55 
    66class 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) 
    918 
    1019    def date_extract_sql(self, lookup_type, field_name): 
     
    5362                table_name = sequence_info['table'] 
    5463                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) 
    6666                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                ) 
    7772            return sql 
    7873        else: 
  • django/branches/newforms-admin/django/db/backends/postgresql_psycopg2/base.py

    r5984 r6014  
    6565        if set_tz: 
    6666            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('.')] 
    7067        return cursor 
  • django/branches/newforms-admin/django/__init__.py

    r5475 r6014  
    55    v = '.'.join([str(i) for i in VERSION[:-1]]) 
    66    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()) 
    89    return v 
  • django/branches/newforms-admin/docs/add_ons.txt

    r5828 r6014  
    139139You can pass in either an integer or a string representation of an integer. 
    140140 
     141naturalday 
     142---------- 
     143 
     144**New in Django development version** 
     145 
     146For dates that are the current day or within one day, return "today", 
     147"tomorrow" or "yesterday", as appropriate. Otherwise, format the date using 
     148the passed in format string. 
     149 
     150**Argument:** Date formatting string as described in default tag now_. 
     151 
     152.. _now: ../templates/#now 
     153 
     154Examples (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 
    141164flatpages 
    142165========= 
  • django/branches/newforms-admin/docs/db-api.txt

    r5828 r6014  
    208208The ``save()`` method has no return value. 
    209209 
    210 Updating ``ForeignKey`` fields works exactly the same way; simply assign an 
    211 object of the right type to the field in question:: 
     210Saving ForeignKey and ManyToManyField fields 
     211-------------------------------------------- 
     212 
     213Updating ``ForeignKey`` fields works exactly the same way as saving a normal 
     214field; 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 
     220Updating a ``ManyToManyField`` works a little differently; use the ``add()`` 
     221method on the field to add a record to the relation:: 
    212222 
    213223    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 
     226Django will complain if you try to assign or add an object of the wrong type. 
    218227 
    219228How Django knows to UPDATE vs. INSERT 
  • django/branches/newforms-admin/docs/django-admin.txt

    r5918 r6014  
    124124post-synchronization handlers will be re-executed, and the ``initial_data`` 
    125125fixture will be re-installed. 
     126 
     127The behavior of this command has changed in the Django development version. 
     128Previously, this command cleared *every* table in the database, including any 
     129table that Django didn't know about (i.e., tables that didn't have associated 
     130models and/or weren't in ``INSTALLED_APPS``). Now, the command only clears 
     131tables that are represented by Django models and are activated in 
     132``INSTALLED_APPS``. 
    126133 
    127134inspectdb 
     
    241248runfcgi [options] 
    242249----------------- 
     250 
    243251Starts a set of FastCGI processes suitable for use with any web server 
    244252which supports the FastCGI protocol. See the `FastCGI deployment 
     
    338346 
    339347sqlclear [appname appname ...] 
    340 -------------------------------------- 
     348------------------------------ 
    341349 
    342350Prints the DROP TABLE SQL statements for the given appnames. 
     
    361369Note that the order in which the SQL files are processed is undefined. 
    362370 
     371sqlflush 
     372-------- 
     373 
     374Prints the SQL statements that would be executed for the `flush`_ command. 
     375 
    363376sqlindexes [appname appname ...] 
    364 ---------------------------------------- 
     377-------------------------------- 
    365378 
    366379Prints the CREATE INDEX SQL statements for the given appnames. 
    367380 
    368381sqlreset [appname appname ...] 
     382------------------------------ 
     383 
     384Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given appnames. 
     385 
     386sqlsequencereset [appname appname ...] 
    369387-------------------------------------- 
    370  
    371 Prints the DROP TABLE SQL, then the CREATE TABLE SQL, for the given appnames. 
    372  
    373 sqlsequencereset [appname appname ...] 
    374 ---------------------------------------------- 
    375388 
    376389Prints the SQL statements for resetting sequences for the given 
  • django/branches/newforms-admin/docs/faq.txt

    r5828 r6014  
    205205spend a lot of energy creating screencasts yet, because Django APIs will shift. 
    206206 
    207 In the meantime, though, check out this `unofficial Django screencast`_. 
    208  
    209 .. _unofficial Django screencast: http://www.throwingbeans.org/django_screencasts.html 
    210  
    211207Is Django a content-management-system (CMS)? 
    212208-------------------------------------------- 
  • django/branches/newforms-admin/docs/model-api.txt

    r5918 r6014  
    345345~~~~~~~~~~~~~~ 
    346346 
    347 Like ``FileField``, but validates that the uploaded object is a valid 
     347Like `FileField`_, but validates that the uploaded object is a valid 
    348348image. Has two extra optional arguments, ``height_field`` and 
    349349``width_field``, which, if set, will be auto-populated with the height and 
  • django/branches/newforms-admin/docs/newforms.txt

    r5986 r6014  
    14631463    ``CheckboxInput``             ``<input type='checkbox' ...`` 
    14641464    ``Select``                    ``<select><option ...`` 
    1465     ``NullBooleanSelect``         Select widget with options 'Unknown',  
     1465    ``NullBooleanSelect``         Select widget with options 'Unknown', 
    14661466                                  'Yes' and 'No' 
    14671467    ``SelectMultiple``            ``<select multiple='multiple'><option ...`` 
    1468     ``RadioSelect``               ``<ul><li><input type='radio' ...``  
     1468    ``RadioSelect``               ``<ul><li><input type='radio' ...`` 
    14691469    ``CheckboxSelectMultiple``    ``<ul><li><input type='checkbox' ...`` 
    14701470    ``MultiWidget``               Wrapper around multiple other widgets 
     
    14771477 
    14781478Whenever 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  
     1479that is appropriate to the type of data that is to be displayed. To find 
    14801480which widget is used on which field, see the documentation for the 
    14811481built-in Field classes. 
    14821482 
    1483 However, if you want to use a different widget for a field, you can -  
     1483However, if you want to use a different widget for a field, you can - 
    14841484just use the 'widget' argument on the field definition. For example:: 
    14851485 
     
    14881488        url = forms.URLField() 
    14891489        comment = forms.CharField(widget=forms.Textarea) 
    1490          
    1491 This would specify a form with a comment that uses a larger Textarea widget,  
     1490 
     1491This would specify a form with a comment that uses a larger Textarea widget, 
    14921492rather than the default TextInput widget. 
    14931493 
     
    15001500on your web page. 
    15011501 
    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  
     1502If you want to make one widget look different to another, you need to 
     1503specify additional attributes for each widget. When you specify a 
    15041504widget, you can provide a list of attributes that will be added to the 
    15051505rendered HTML for the widget. 
     
    15231523 
    15241524On 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  
     1525might 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 
     1527custom widget for your fields, and specify some attributes to use 
    15281528when rendering those widgets:: 
    15291529 
    15301530    class CommentForm(forms.Form): 
    1531         name = forms.CharField(                    
     1531        name = forms.CharField( 
    15321532                    widget=forms.TextInput(attrs={'class':'special'})) 
    15331533        url = forms.URLField() 
     
    15471547 
    15481548When 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  
     1549reuse certain sets of widget attributes over and over again. Rather than 
     1550repeat these attribute definitions every time you need them, Django allows 
    15511551you to capture those definitions as a custom widget. 
    15521552 
    15531553For 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  
     1554you could capture the idea of a ``TextInput`` with a specific ``size`` attribute 
    15551555as a custom extension to the ``TextInput`` widget:: 
    15561556 
     
    15581558        def __init__(self, *args, **kwargs): 
    15591559            kwargs.setdefault('attrs',{}).update({'size': '40'}) 
    1560             super(forms.TextInput, self).__init__(*args, **kwargs) 
    1561              
     1560            super(CommentWidget, self).__init__(*args, **kwargs) 
     1561 
    15621562Then you can use this widget in your forms:: 
    15631563 
     
    15671567        comment = forms.CharField(widget=CommentWidget) 
    15681568 
    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  
     1569You can even customize your custom widget, in the same way as you would 
     1570any other widget. Adding a once-off class to your ``CommentWidget`` is as 
    15711571simple as adding an attribute definition:: 
    15721572 
     
    15831583    class CommentInput(forms.CharField): 
    15841584        widget = CommentWidget 
    1585          
     1585 
    15861586You can then use this field whenever you have a form that requires a comment:: 
    15871587 
     
    15901590        url = forms.URLField() 
    15911591        comment = CommentInput() 
    1592          
     1592 
    15931593Generating forms for models 
    15941594=========================== 
     
    19351935arguments that behave the same way as they do for ``form_for_model()``. 
    19361936 
     1937Let's modify the earlier `contact form`_ view example a little bit. Suppose we 
     1938have 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 
     1946You could use this model to create a form (using ``form_for_model()``). You 
     1947could also use existing ``Message`` instances to create a form for editing 
     1948messages. The earlier_ view can be changed slightly to accept the ``id`` value 
     1949of 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 
     1965Aside from how we create the ``ContactForm`` class here, the main point to 
     1966note is that the form display in the ``GET`` branch of the function 
     1967will use the values from the ``message`` instance as initial values for the 
     1968form field. 
     1969 
     1970.. _contact form: `Simple view example`_ 
     1971.. _earlier: `Simple view example`_ 
     1972 
    19371973When should you use ``form_for_model()`` and ``form_for_instance()``? 
    19381974~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
  • django/branches/newforms-admin/docs/settings.txt

    r5627 r6014  
    11021102---------- 
    11031103 
    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.) 
     1104When ``DEBUG`` is ``False``, ``SEND_BROKEN_LINK_EMAILS`` is ``True`` and your 
     1105``MIDDLEWARE_CLASSES`` setting includes ``CommonMiddleware``, Django will 
     1106e-mail the users listed in the ``MANAGERS`` setting whenever your code raises 
     1107a 404 and the request has a referer. (It doesn't bother to e-mail for 404s 
     1108that don't have a referer.) 
    11081109 
    11091110You can tell Django to stop reporting particular 404s by tweaking the 
  • django/branches/newforms-admin/docs/testing.txt

    r5918 r6014  
    474474 
    475475        >>> c = Client() 
    476         >>> c.get('/login/', {'name': 'fred', 'passwd': 'secret'}) 
     476        >>> c.post('/login/', {'name': 'fred', 'passwd': 'secret'}) 
    477477 
    478478    ...will result in the evaluation of a POST request to this URL:: 
  • django/branches/newforms-admin/docs/tutorial01.txt

    r5918 r6014  
    259259        choice = models.CharField(max_length=200) 
    260260        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/ 
    261277 
    262278The code is straightforward. Each model is represented by a class that 
     
    488504            return self.choice 
    489505 
     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 
    490523It's important to add ``__unicode__()`` methods to your models, not only for 
    491524your own sanity when dealing with the interactive prompt, but also because 
  • django/branches/newforms-admin/tests/regressiontests/humanize/tests.py

    r5918 r6014  
    11import unittest 
     2from datetime import timedelta, date 
    23from django.template import Template, Context, add_to_builtins 
     4from django.utils.dateformat import DateFormat 
     5from django.utils.translation import ugettext as _ 
    36 
    47add_to_builtins('django.contrib.humanize.templatetags.humanize') 
     
    912        # Using max below ensures we go through both lists 
    1013        # 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))): 
    1215            test_content = test_list[index] 
    1316            t = Template('{{ test_content|%s }}' % method) 
    1417            rendered = t.render(Context(locals())).strip() 
    1518            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])) 
    1820 
    1921    def test_ordinal(self): 
     
    5052        self.humanize_tester(test_list, result_list, 'apnumber') 
    5153 
     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 
    5268if __name__ == '__main__': 
    5369    unittest.main()