Answer the question
In order to leave comments, you need to log in
How to define Permission in the model for a field?
Hello everyone, I have such a problem, in my custom user model there is a balance field, I display it in the user profile, but the problem is that any user can change it, and I need only the admin to be able to change the field or the one who has permission is to do permission.
I read that you can add permission to the model in Meta, for example, to edit a field:
class Meta:
permissions = (
("can_edit_meta", "Can edit meta tags"),
)
Answer the question
In order to leave comments, you need to log in
(?=^\S+(\s\S+(\s\S+)?)?$)^[а-яА-ЯёЁa-zA-Z0-9\s]+$
https://regex101.com/r/8E8w2k/1
Like all other rights
if user.has_perm('your_app.can_edit_meta'):
# good mojo
else:
# bad mojo
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question