Changes between Version 73 and Version 74 of RemovingTheMagic
- Timestamp:
- Feb 25, 2006, 12:52:12 PM (19 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
RemovingTheMagic
v73 v74 555 555 === Changed the parameters you pass to generic views === 556 556 557 '''This has been made obsolete by QuerySets''' 558 ---- 559 ~~Because there's no longer a concept of {{{module_name}}}, the "info_dicts" passed to [http://www.djangoproject.com/documentation/generic_views/ generic views] no longer accept {{{"app_label"}}} and {{{"module_name"}}}. Instead, pass the parameter {{{"model"}}}, which should be your model class.~~ 560 561 ~~These examples assume models live in {{{myproject/blog/models.py}}}.~~ 562 ---- 563 564 '''Generic Views now use QuerySets instead of the 'model' argument''' 565 566 Oldest: 557 Because there's no longer a concept of {{{module_name}}}, the "info_dicts" passed to [http://www.djangoproject.com/documentation/generic_views/ generic views] no longer accept {{{"app_label"}}} and {{{"module_name"}}}. Instead, pass the parameter {{{"queryset"}}}, which should be a {{{QuerySet}}} instance. 558 559 Old: 567 560 {{{ 568 561 #!python … … 573 566 }}} 574 567 575 Older:568 New: 576 569 {{{ 577 570 #!python 578 571 from myproject.blog.models import Entry 579 info_dict = {'model': Entry} 580 }}} 581 582 New: 583 {{{ 584 #!python 585 from myproject.blog.models import Entry 586 info_dict = {'queryset': Entry.objects} 587 }}} 588 589 Or: 590 591 {{{ 592 #!python 593 urlpatterns = patterns('', 594 (r'^(?P<object_id>\d+)/$', 'django.views.generic.list_detail.object_detail', {'queryset': Entry.objects.all()}) 595 ) 572 info_dict = {'queryset': Entry.objects.all()} 596 573 }}} 597 574