I also think you are talking about to different things.

Thomas, I get a feeling you are not using the default permissions system
built into django, but rather using your own. Regardless of how you do it -
you could just add a method on the user object that is :

def has_permission(self, permission)

In that method you can do checking for the super user and then also for the
specifik permission you need. That way you only check it in one place and
it won't ruin your code.

Regards,

Andréas

2017-03-17 9:53 GMT+01:00 guettli <guettli.goo...@thomas-guettler.de>:

> It's not a problem. It something else. I am missing the right words ... I
> know how to use conditions in python or the equivalent sql operations.
>
> I am sure that my code would be simpler if the superuser would not have
> all permissions.
>
> I am sure if I want to go this way, since django does it different.
>
> It's not a problem. Maybe it is event not a thought of my brain. It is
> more a feeling or big dream: simpler code with less conditions.
>
> Regards,
>   Thomas
>
>
> Am Donnerstag, 16. März 2017 15:29:15 UTC+1 schrieb Jani Tiainen:
>>
>> Hi,
>>
>> You don't need to check for superuser explicitly Django does that when
>> you check does user have a permission and returns true for all perm checks.
>> So it's just simple check.
>>
>> Unless you meant something else, maybe giving a sample code would help
>> understand your problem better.
>>
>> On 16.03.2017 11:29, guettli wrote:
>>
>> This is not a question, just a feeling. I want to know if you feel the
>> same pain.
>>
>> Checking for permission in django is done in two steps:
>>
>>  check1: check if user is superuser, then user is allowed.
>>  check2: check if user has the given permission.
>>
>> This OR is solvable. It's easy to code. It is just a simple "if".
>>
>> The OR can be done in SQL, too.... But not much better.
>>
>> But somehow it makes my code messy.
>>
>> I would like to get the answer directly from postgres/DB, I don't write a
>> condition.
>>
>> I want it to be straight forward.
>>
>> In our custom code we already skip check1 and do only check2.
>>
>> But this makes the whole situation not much better.
>>
>> I am just speaking out my thoughts.
>>
>> Dear django (core) developer: I like django very much and it is a great
>> framework which I use daily with joy. Don't get me wrong!
>>
>> Unfortunately I have no clue which strategy could lead me to the goal if
>> this particular issue without
>> doing stuff in my code completely different than django does. I want to
>> avoid doing uncommon things
>> and stick to upstream.
>>
>> Regards,
>>   Thomas Güttler
>>
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users...@googlegroups.com.
>> To post to this group, send email to django...@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> <https://groups.google.com/d/msgid/django-users/d629dba5-cc73-4625-9d91-92741b7010a2%40googlegroups.com?utm_medium=email&utm_source=footer>
>> https://groups.google.com/d/msgid/django-users/d629dba5-cc73
>> -4625-9d91-92741b7010a2%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>> --
>> Jani Tiainen
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/62cdebd9-3950-4391-875e-9d04e5a896c6%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/62cdebd9-3950-4391-875e-9d04e5a896c6%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK4qSCdBzO4WraQcFoXHMcPGT3nVeKEvge-TCWU3z_zhK%2B%2BjDA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to