Changes between Version 73 and Version 74 of RemovingTheMagic


Ignore:
Timestamp:
02/25/2006 12:52:12 PM (9 years ago)
Author:
adrian
Comment:

Cleanup of generic-views section

Legend:

Unmodified
Added
Removed
Modified
  • RemovingTheMagic

    v73 v74  
    555555=== Changed the parameters you pass to generic views ===
    556556
    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:
     557Because 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
     559Old:
    567560{{{
    568561#!python
     
    573566}}}
    574567
    575 Older:
     568New:
    576569{{{
    577570#!python
    578571from 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 )
     572info_dict = {'queryset': Entry.objects.all()}
    596573}}}
    597574
Back to Top