How Django control permission to display a button (reprint)

V2EX   ›  Python
 

Ask: Django how to control permission to display a button ah

  
   ns2250225  · 2017-11-19 11:24:18 +08: 00 · 1639 views
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
 
Macuilxochitl    2017-11-19 13:21:12 +08: 00    ♥ 1
 
Or if the template with the front end to control
 
     2
 
flipped123   2017-11-20 09:14:21 +08:00
 
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
 
flipped123   2017-11-20 09:15:00 +08:00   ♥ 1
 
user.has_perms()

Guess you like

Origin www.cnblogs.com/master-road/p/11103036.html