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

2023-02-18 14:39:58 浏览数 (2)

django2 报错:

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

解决办法:

代码语言:javascript复制
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

0 人点赞