Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python django cbv服务受密码保护的静态内容_Python_Django_Static - Fatal编程技术网

Python django cbv服务受密码保护的静态内容

Python django cbv服务受密码保护的静态内容,python,django,static,Python,Django,Static,对于django应用程序中的每个用户,我都会生成一个我想要提供服务的静态.ical文件。是否有CBV,我将覆盖哪种方法? 由于我的所有视图都是基于类的,因此我不希望使用带有HttpResponse和@auth\u required装饰器的基于函数的视图,因为: 只需继承视图模型并重写视图方法 class ICalDownload(View): def get(self, *args, **kwargs): # return your response just like

对于django应用程序中的每个用户,我都会生成一个我想要提供服务的静态.ical文件。是否有CBV,我将覆盖哪种方法? 由于我的所有视图都是基于类的,因此我不希望使用带有
HttpResponse
@auth\u required
装饰器的基于函数的视图,因为:

只需继承
视图
模型并重写视图方法

class ICalDownload(View):
    def get(self, *args, **kwargs):
        # return your response just like you would in a function view.
如果您想保护视图,我喜欢使用。否则,您需要在分派方法上使用
方法\u decorator

@method_decorator(auth_required)
def dispatch(self, *args, **kwargs):
    return super(ICalDownload, self).dispatch(*args, **kwargs)
在这一点上,基于函数的视图可能会简单一些,但和您一样,我喜欢始终使用基于类的视图