S
S
slickstars2015-09-03 18:13:21
Regular Expressions
slickstars, 2015-09-03 18:13:21

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"),
        )

But how to use this permission?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
Evgeny Samsonov, 2019-03-24
@Fagi

(?=^\S+(\s\S+(\s\S+)?)?$)^[а-яА-ЯёЁa-zA-Z0-9\s]+$
https://regex101.com/r/8E8w2k/1

D
Dmitry, 2019-03-24
@demon416nds

https://ru.stackoverflow.com/questions/448942/How-...

R
Roman Kitaev, 2015-09-03
@slickstars

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 question

Ask a Question

731 491 924 answers to any question