4
我在Django很新,想知道在像ListView這樣的通用視圖中定義模型與查詢集有什麼區別。這裏是我的代碼示例中的項目我的urls.py文件:Django - 查詢集與通用視圖中的模型
urlpatterns = patterns('',
url(r'^$', ListView.as_view(
model=Person,
context_object_name='people',
template_name='index.html',
)),
)
我也用相同的:
urlpatterns = patterns('',
url(r'^$', ListView.as_view(
queryset=Person.objects.all,
context_object_name='people',
template_name='index.html',
)),
)
並收到了我的看法相同的結果。我假設你可以用一個查詢集做不同的事情?
好的,這是有道理的,謝謝! – yeenow123 2012-07-08 19:32:41