Changeset 2455
- Timestamp:
- 02/28/06 21:57:57 (3 years ago)
- Files:
-
- django/branches/magic-removal/AUTHORS (modified) (1 diff)
- django/branches/magic-removal/django/db/models/fields/__init__.py (modified) (2 diffs)
- django/branches/magic-removal/django/views/generic/create_update.py (modified) (4 diffs)
- django/branches/magic-removal/django/views/generic/date_based.py (modified) (6 diffs)
- django/branches/magic-removal/django/views/generic/list_detail.py (modified) (5 diffs)
- django/branches/magic-removal/docs/generic_views.txt (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/branches/magic-removal/AUTHORS
r2351 r2455 46 46 C8E 47 47 Amit Chakradeo <http://amit.chakradeo.net/> 48 ChaosKCW 48 49 Matt Croydon <http://www.postneo.com/> 49 50 Jonathan Daugherty (cygnus) <http://www.cprogrammer.org/> django/branches/magic-removal/django/db/models/fields/__init__.py
r2410 r2455 10 10 import datetime, os 11 11 12 # Random entropy string used by "default" param. 13 NOT_PROVIDED = 'oijpwojefiojpanv' 12 class NOT_PROVIDED: 13 pass 14 14 15 15 # Values for filter_interface. … … 159 159 def has_default(self): 160 160 "Returns a boolean of whether this field has a default value." 161 return self.default !=NOT_PROVIDED161 return self.default is not NOT_PROVIDED 162 162 163 163 def get_default(self): 164 164 "Returns the default value for this field." 165 if self.default !=NOT_PROVIDED:165 if self.default is not NOT_PROVIDED: 166 166 if callable(self.default): 167 167 return self.default() django/branches/magic-removal/django/views/generic/create_update.py
r2373 r2455 73 73 slug_field=None, template_name=None, template_loader=loader, 74 74 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'): 76 77 """ 77 78 Generic object-update function. … … 131 132 c = RequestContext(request, { 132 133 'form': form, 133 'object': object,134 template_object_name: object, 134 135 }, context_processors) 135 136 for key, value in extra_context.items(): … … 145 146 object_id=None, slug=None, slug_field=None, template_name=None, 146 147 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'): 148 149 """ 149 150 Generic object-delete function. … … 185 186 t = template_loader.get_template(template_name) 186 187 c = RequestContext(request, { 187 'object': object,188 template_object_name: object, 188 189 }, context_processors) 189 190 for key, value in extra_context.items(): django/branches/magic-removal/django/views/generic/date_based.py
r2405 r2455 81 81 def archive_month(request, year, month, queryset, date_field, 82 82 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'): 84 85 """ 85 86 Generic monthly archive view. … … 120 121 t = template_loader.get_template(template_name) 121 122 c = RequestContext(request, { 122 ' object_list': object_list,123 '%s_list' % template_object_name: object_list, 123 124 'month': date, 124 125 'next_month': (last_day < datetime.date.today()) and (last_day + datetime.timedelta(days=1)) or None, … … 135 136 month_format='%b', day_format='%d', template_name=None, 136 137 template_loader=loader, extra_context={}, allow_empty=False, 137 context_processors=None ):138 context_processors=None, template_object_name='object'): 138 139 """ 139 140 Generic daily archive view. … … 170 171 t = template_loader.get_template(template_name) 171 172 c = RequestContext(request, { 172 ' object_list': object_list,173 '%s_list' % template_object_name: object_list, 173 174 'day': date, 174 175 'previous_day': date - datetime.timedelta(days=1), … … 197 198 month_format='%b', day_format='%d', object_id=None, slug=None, 198 199 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'): 200 202 """ 201 203 Generic detail view from year/month/day/slug or year/month/day/id structure. … … 237 239 t = template_loader.get_template(template_name) 238 240 c = RequestContext(request, { 239 'object': obj,241 template_object_name: obj, 240 242 }, context_processors) 241 243 for key, value in extra_context.items(): django/branches/magic-removal/django/views/generic/list_detail.py
r2428 r2455 7 7 def object_list(request, queryset, paginate_by=None, allow_empty=False, 8 8 template_name=None, template_loader=loader, 9 extra_context={}, context_processors=None ):9 extra_context={}, context_processors=None, template_object_name='object'): 10 10 """ 11 11 Generic list of objects. … … 48 48 raise Http404 49 49 c = RequestContext(request, { 50 ' object_list': object_list,50 '%s_list' % template_object_name: object_list, 51 51 'is_paginated': paginator.pages > 1, 52 52 'results_per_page': paginate_by, … … 61 61 else: 62 62 c = RequestContext(request, { 63 ' object_list': queryset,63 '%s_list' % template_object_name: queryset, 64 64 'is_paginated': False 65 65 }, context_processors) … … 79 79 slug_field=None, template_name=None, template_name_field=None, 80 80 template_loader=loader, extra_context={}, 81 context_processors=None ):81 context_processors=None, template_object_name='object'): 82 82 """ 83 83 Generic list of objects. … … 107 107 t = template_loader.get_template(template_name) 108 108 c = RequestContext(request, { 109 'object': obj,109 template_object_name: obj, 110 110 }, context_processors) 111 111 for key, value in extra_context.items(): django/branches/magic-removal/docs/generic_views.txt
r2339 r2455 189 189 190 190 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'``. 191 195 192 196 Uses the template ``<app_label>/<model_name>_archive_month`` by default. … … 204 208 previous month (a datetime.date object) 205 209 ``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``. 207 215 208 216 ``archive_day`` … … 214 222 decimal number, 1-31). 215 223 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 216 228 Uses the template ``<app_label>/<model_name>_archive_day`` by default. 217 229 … … 219 231 220 232 ``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``. 222 238 ``day`` 223 239 The given day (a datetime.datetime object) … … 251 267 and ``day_format`` parameters. 252 268 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 253 273 .. _strftime docs: http://www.python.org/doc/current/lib/module-time.html#l2h-1941 254 274 … … 282 302 the view will raise a 404 instead of displaying 283 303 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'``. 284 307 ======================= ================================================= 285 308 … … 289 312 290 313 ``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``. 292 319 ``is_paginated`` 293 320 Are the results paginated? Either True or False … … 359 386 ``post_save_redirect`` as ``create_object`` does. 360 387 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 361 392 Uses the template ``<app_label>/<model_name>_form`` by default. 362 393 … … 366 397 The form wrapper for the object 367 398 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``. 369 404 370 405 ``delete_object`` … … 381 416 if POSTed -- it simply deletes the object and redirects. 382 417 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 383 422 Has the following template context: 384 423 385 424 object 386 425 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``.
