﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
16970	calling as_view of CBV in URLConf needs better documentation and examples	Daniel Greenfeld	nobody	"Say I have a ListView that calls on a Thing model. Thing model has it's own Model Manager that adds query method called 'some_things'. In theory I code it thus:

{{{#!python
url(regex=r'^$',
    view=ListView.as_view(
        queryset=Thing.objects.some_things(),
        template_name='things/some_things.html'),
    name='some_things',    
    ),    
}}}

However, (MultipleObjectMixin.get_queryset) https://code.djangoproject.com/browser/django/trunk/django/views/generic/list.py shows that if a model is not defined in the ListView arguments, that the default manager '''all''' method is called. Which means if you want to get the behavior you want you need to do:

{{{#!python
url(regex=r'^$',
    view=ListView.as_view(
        model=Job,
        queryset=Thing.objects.some_things(),
        template_name='things/some_things.html'),
    name='some_things',    
    ),    
}}}

See how I added an explicit model call?

Figuring this out meant rooting through Django source code. What I propose is documenting this behavior in the pages on Class Based Views. I would do it myself but it is unclear where I should put said documentation (topic or not?). "	New feature	closed	Documentation	1.3	Normal	fixed		me@…	Accepted	0	0	0	0	0	0
