login_required decorator in django

前端 未结 3 2250
遥遥无期
遥遥无期 2021-02-12 22:13

Is there any difference in using login_required decorator in urls.py and in views.py ? If I put this line:

url(r\'^add/$\', login_required(views.add_media), name         


        
3条回答
  •  离开以前
    2021-02-12 23:12

    Yes, they are the same. Decorators are syntactic sugar for wrapping a function in another one. So in either case, you are wrapping login_required around views.add_media.

提交回复
热议问题