#NEWLINE# def add_permission( user , model , permission_codename ) : #NEWLINE# #INDENT# "Add a permission to a user.\n\n    Creates the permission if it doesn't exist.\n\n    " #NEWLINE# content_type = ContentType . objects . get_for_model ( model ) #NEWLINE# ( permission , created ) = Permission . objects . get_or_create ( codename = permission_codename , content_type = content_type , defaults = { #NEWLINE# #INDENT# 'name' : created , #NEWLINE# #UNINDENT# } ) #NEWLINE# user . user_permissions . add ( permission )