V2EX
› Python
ns2250225 · 2017-11-19 11:24:18 +08: 00 · 1639 views
Ask: Django how to control permission to display a button ah
This is a theme to create 586 days ago, in which the information may have been developed or changed.
As the title
3 Reply | until 2017-11-20 09:15:00 +08: 00
1
Or if the template with the front end to control
|
2
Right floor in the template code {% if self.has_perms ( 'can view')%} <button> button </ button> {% else%} nothing {% end if%}. About a function to determine whether the user has permission, you could see the official documents, several functions can be used, I do not remember it.
|
3
user.has_perms()
|