zl程序教程

您现在的位置是:首页 >  工具

当前栏目

django2 TypeError: RedirectView() received an invalid keyword 're_path'. as_view only accepts argume

invalid &# View an as Only path x27
2023-06-13 09:18:40 时间

django2 报错:

TypeError: RedirectView() received an invalid keyword 're_path'. as_view only accepts arguments that are already attributes of the class.

解决办法:

from django.views.generic.base import RedirectView  # favicon.ico


# favicon_view = RedirectView.as_view(re_path='/static/images/zhuo_64x64.ico', permanent=True)  # django 1.11
favicon_view = RedirectView.as_view(url='/static/images/zhuo_64x64.ico', permanent=True)  # django 2.2