Questions tagged «django-generic-views»

7
Django基于类的视图:如何将其他参数传递给as_view方法?
我有一个基于类的自定义视图 # myapp/views.py from django.views.generic import * class MyView(DetailView): template_name = 'detail.html' model = MyModel def get_object(self, queryset=None): return queryset.get(slug=self.slug) 我想像这样传递slug参数(或其他参数到视图) MyView.as_view(slug='hello_world') 我是否需要重写任何方法才能做到这一点?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.