Guest User

Untitled

a guest
Nov 20th, 2017
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. #### модель
  2. class Access(models.Model):
  3.  
  4.     class Meta:
  5.  
  6.         managed = False
  7.  
  8.         permissions = (
  9.             ('customer_rights', 'Global customer rights'),
  10.             ('access', 'Roots')
  11.         )
  12.  
  13.  
  14.  
  15. ####### вьюшка
  16. content_type = ContentType.objects.get(app_label='registration', model='access')
  17. permission = Permission.objects.get_or_create(codename='rights',
  18.                                               name='Global customer rights',
  19.                                               content_type=content_type)
  20.                
  21. user = User.objects.create_user(username=form.cleaned_data.get('email'),
  22.                                 password=form.cleaned_data.get('password'))
  23. user.save()
  24. user.user_permissions.add(permission)
Add Comment
Please, Sign In to add comment