回到顶部

Contents

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

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

 

^_^
请喝咖啡 ×

前一篇: How to Add a Text Filter to Django Admin
下一篇: 'django.contrib.auth.middleware.AuthenticationMiddleware' must be in MIDDLEWARE in order to use the admin application.
captcha