Hi All
I am developing a simple app in which i have to play with user
permissions.I register a user(during a sign up process) with this method :-
def register_user(data):
"""
This method is used to register a new user and create a user profile.
"""
password = hashlib.sha1(data['confirm_password']).hexdigest()
new_user = User(username=data['email'], email=data['email'],
is_staff=True
)
new_user.set_password(data['confirm_password'])
# At this point i want to add user_permissions ! How can i do this ?
new_user.user_premissions.add('can add table_name') @ Since it is a
manytomany field
How can i set permissions from this part of code ?
new_user.save()
new_user.first_name = data['title']
new_user.email = data['email']
new_user.is_locked = True
new_user.save()
new_user.user_permissions('Can add department')
profile = new_user.profile
key = uuid.uuid4().__str__()
profile.key = key
profile.save()
if new_user and profile:
return new_user
else:
return False
Thanks in advance
--
Regards
Nikhil Verma
+91-958-273-3156
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.