Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #### модель
- class Access(models.Model):
- class Meta:
- managed = False
- permissions = (
- ('customer_rights', 'Global customer rights'),
- ('access', 'Roots')
- )
- ####### вьюшка
- content_type = ContentType.objects.get(app_label='registration', model='access')
- permission = Permission.objects.get_or_create(codename='rights',
- name='Global customer rights',
- content_type=content_type)
- user = User.objects.create_user(username=form.cleaned_data.get('email'),
- password=form.cleaned_data.get('password'))
- user.save()
- user.user_permissions.add(permission)
Add Comment
Please, Sign In to add comment