Django

Code

Changeset 2455

Show
Ignore:
Timestamp:
02/28/06 21:57:57 (3 years ago)
Author:
adrian
Message:

magic-removal: Merged to [2454]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/branches/magic-removal/AUTHORS

    r2351 r2455  
    4646    C8E 
    4747    Amit Chakradeo <http://amit.chakradeo.net/> 
     48    ChaosKCW 
    4849    Matt Croydon <http://www.postneo.com/> 
    4950    Jonathan Daugherty (cygnus) <http://www.cprogrammer.org/> 
  • django/branches/magic-removal/django/db/models/fields/__init__.py

    r2410 r2455  
    1010import datetime, os 
    1111 
    12 # Random entropy string used by "default" param. 
    13 NOT_PROVIDED = 'oijpwojefiojpanv' 
     12class NOT_PROVIDED: 
     13    pass 
    1414 
    1515# Values for filter_interface. 
     
    159159    def has_default(self): 
    160160        "Returns a boolean of whether this field has a default value." 
    161         return self.default != NOT_PROVIDED 
     161        return self.default is not NOT_PROVIDED 
    162162 
    163163    def get_default(self): 
    164164        "Returns the default value for this field." 
    165         if self.default != NOT_PROVIDED: 
     165        if self.default is not NOT_PROVIDED: 
    166166            if callable(self.default): 
    167167                return self.default() 
  • django/branches/magic-removal/django/views/generic/create_update.py

    r2373 r2455  
    7373        slug_field=None, template_name=None, template_loader=loader, 
    7474        extra_lookup_kwargs={}, extra_context={}, post_save_redirect=None, 
    75         login_required=False, follow=None, context_processors=None): 
     75        login_required=False, follow=None, context_processors=None, 
     76        template_object_name='object'): 
    7677    """ 
    7778    Generic object-update function. 
     
    131132    c = RequestContext(request, { 
    132133        'form': form, 
    133         'object': object, 
     134        template_object_name: object, 
    134135    }, context_processors) 
    135136    for key, value in extra_context.items(): 
     
    145146        object_id=None, slug=None, slug_field=None, template_name=None, 
    146147        template_loader=loader, extra_lookup_kwargs={}, extra_context={}, 
    147         login_required=False, context_processors=None): 
     148        login_required=False, context_processors=None, template_object_name='object'): 
    148149    """ 
    149150    Generic object-delete function. 
     
    185186        t = template_loader.get_template(template_name) 
    186187        c = RequestContext(request, { 
    187             'object': object, 
     188            template_object_name: object, 
    188189        }, context_processors) 
    189190        for key, value in extra_context.items(): 
  • django/branches/magic-removal/django/views/generic/date_based.py

    r2405 r2455  
    8181def archive_month(request, year, month, queryset, date_field, 
    8282        month_format='%b', template_name=None, template_loader=loader, 
    83         extra_context={}, allow_empty=False, context_processors=None): 
     83        extra_context={}, allow_empty=False, context_processors=None, 
     84        template_object_name='object'): 
    8485    """ 
    8586    Generic monthly archive view. 
     
    120121    t = template_loader.get_template(template_name) 
    121122    c = RequestContext(request, { 
    122         'object_list': object_list, 
     123        '%s_list' % template_object_name: object_list, 
    123124        'month': date, 
    124125        'next_month': (last_day < datetime.date.today()) and (last_day + datetime.timedelta(days=1)) or None, 
     
    135136        month_format='%b', day_format='%d', template_name=None, 
    136137        template_loader=loader, extra_context={}, allow_empty=False, 
    137         context_processors=None): 
     138        context_processors=None, template_object_name='object'): 
    138139    """ 
    139140    Generic daily archive view. 
     
    170171    t = template_loader.get_template(template_name) 
    171172    c = RequestContext(request, { 
    172         'object_list': object_list, 
     173        '%s_list' % template_object_name: object_list, 
    173174        'day': date, 
    174175        'previous_day': date - datetime.timedelta(days=1), 
     
    197198        month_format='%b', day_format='%d', object_id=None, slug=None, 
    198199        slug_field=None, template_name=None, template_name_field=None, 
    199         template_loader=loader, extra_context={}, context_processors=None): 
     200        template_loader=loader, extra_context={}, context_processors=None, 
     201        template_object_name='object'): 
    200202    """ 
    201203    Generic detail view from year/month/day/slug or year/month/day/id structure. 
     
    237239        t = template_loader.get_template(template_name) 
    238240    c = RequestContext(request, { 
    239         'object': obj, 
     241        template_object_name: obj, 
    240242    }, context_processors) 
    241243    for key, value in extra_context.items(): 
  • django/branches/magic-removal/django/views/generic/list_detail.py

    r2428 r2455  
    77def object_list(request, queryset, paginate_by=None, allow_empty=False, 
    88        template_name=None, template_loader=loader, 
    9         extra_context={}, context_processors=None): 
     9        extra_context={}, context_processors=None, template_object_name='object'): 
    1010    """ 
    1111    Generic list of objects. 
     
    4848                raise Http404 
    4949        c = RequestContext(request, { 
    50             'object_list': object_list, 
     50            '%s_list' % template_object_name: object_list, 
    5151            'is_paginated': paginator.pages > 1, 
    5252            'results_per_page': paginate_by, 
     
    6161    else: 
    6262        c = RequestContext(request, { 
    63             'object_list': queryset, 
     63            '%s_list' % template_object_name: queryset, 
    6464            'is_paginated': False 
    6565        }, context_processors) 
     
    7979        slug_field=None, template_name=None, template_name_field=None, 
    8080        template_loader=loader, extra_context={}, 
    81         context_processors=None): 
     81        context_processors=None, template_object_name='object'): 
    8282    """ 
    8383    Generic list of objects. 
     
    107107        t = template_loader.get_template(template_name) 
    108108    c = RequestContext(request, { 
    109         'object': obj, 
     109        template_object_name: obj, 
    110110    }, context_processors) 
    111111    for key, value in extra_context.items(): 
  • django/branches/magic-removal/docs/generic_views.txt

    r2339 r2455  
    189189 
    190190    Takes an optional ``allow_empty`` parameter, as ``archive_index``. 
     191 
     192    **New in Django development version:** Takes an optional 
     193    ``template_object_name`` parameter, which designates the name of the 
     194    template variable to use. Default is ``'object'``. 
    191195 
    192196    Uses the template ``<app_label>/<model_name>_archive_month`` by default. 
     
    204208            previous month (a datetime.date object) 
    205209        ``object_list`` 
    206             List of objects published in the given month 
     210            List of objects published in the given month. 
     211            In the Django development version, you can change this variable 
     212            name from ``object_list`` by using the ``template_object_name`` 
     213            parameter. (See above.) For example, if ``template_object_name`` is 
     214            ``foo``, the variable will be ``foo_list``. 
    207215 
    208216``archive_day`` 
     
    214222    decimal number, 1-31). 
    215223 
     224    **New in Django development version:** Takes an optional 
     225    ``template_object_name`` parameter, which designates the name of the 
     226    template variable to use. Default is ``'object'``. 
     227 
    216228    Uses the template ``<app_label>/<model_name>_archive_day`` by default. 
    217229 
     
    219231 
    220232        ``object_list`` 
    221             List of objects published this day 
     233            List of objects published on the given day. 
     234            In the Django development version, you can change this variable 
     235            name from ``object_list`` by using the ``template_object_name`` 
     236            parameter. (See above.) For example, if ``template_object_name`` is 
     237            ``foo``, the variable will be ``foo_list``. 
    222238        ``day`` 
    223239            The given day (a datetime.datetime object) 
     
    251267    and ``day_format`` parameters. 
    252268 
     269    **New in Django development version:** Takes an optional 
     270    ``template_object_name`` parameter, which designates the name of the 
     271    template variable to use. Default is ``'object'``. 
     272 
    253273.. _strftime docs: http://www.python.org/doc/current/lib/module-time.html#l2h-1941 
    254274 
     
    282302                                 the view will raise a 404 instead of displaying 
    283303                                 an empty index page. ``False`` is default. 
     304        ``template_object_name`` **New in Django development version.** Designates 
     305                                 the name of the object template variable. Default 
     306                                 is ``'object'``. 
    284307        =======================  ================================================= 
    285308 
     
    289312 
    290313        ``object_list`` 
    291             List of objects 
     314            List of objects. In the Django development version, you can change 
     315            this variable name from ``object_list`` by using the 
     316            ``template_object_name`` parameter. (See above.) For example, if 
     317            ``template_object_name`` is ``foo``, the variable will be 
     318            ``foo_list``. 
    292319        ``is_paginated`` 
    293320            Are the results paginated? Either True or False 
     
    359386    ``post_save_redirect`` as ``create_object`` does. 
    360387 
     388    **New in Django development version:** Takes an optional 
     389    ``template_object_name`` parameter, which designates the name of the 
     390    template variable to use. Default is ``'object'``. 
     391 
    361392    Uses the template ``<app_label>/<model_name>_form`` by default. 
    362393 
     
    366397            The form wrapper for the object 
    367398        object 
    368             The original object being edited 
     399            The original object being edited. 
     400            In the Django development version, you can change this variable 
     401            name from ``object`` by using the ``template_object_name`` 
     402            parameter. (See above.) For example, if ``template_object_name`` is 
     403            ``foo``, the variable will be ``foo`` instead of ``object``. 
    369404 
    370405``delete_object`` 
     
    381416    if POSTed -- it simply deletes the object and redirects. 
    382417 
     418    **New in Django development version:** Takes an optional 
     419    ``template_object_name`` parameter, which designates the name of the 
     420    template variable to use. Default is ``'object'``. 
     421 
    383422    Has the following template context: 
    384423 
    385424        object 
    386425            The object about to be deleted 
     426            In the Django development version, you can change this variable 
     427            name from ``object`` by using the ``template_object_name`` 
     428            parameter. (See above.) For example, if ``template_object_name`` is 
     429            ``foo``, the variable will be ``foo`` instead of ``object``.