在这些例子中,我经常看到**没有提到它是从哪里传来传来传kwargs:Django泛型基于类的视图示例:** kwargs来自哪里?
from django.views.generic import DetailView
from books.models import Publisher, Book
class PublisherDetailView(DetailView):
context_object_name = "publisher"
model = Publisher
def get_context_data(self, **kwargs):
# Call the base implementation first to get a context
context = super(PublisherDetailView, self).get_context_data(**kwargs)
# Add in a QuerySet of all the books
context['book_list'] = Book.objects.all()
return context
凡** kwargs被奇迹般地从弹拨?
另外,这似乎不像一个额外的工作只是添加一个单一的字典对象吗?
可能的重复:http://stackoverflow.com/q/1769403/576139 –
我在说这个特定的实例。我知道** kwargs的含义。 –