ઉકેલાયેલ: સ્ટાફ વપરાશકર્તા જેંગોમાં પરવાનગીને પ્રતિબંધિત કરી રહ્યો નથી

પરવાનગીને પ્રતિબંધિત ન કરવાની મુખ્ય સમસ્યા એ છે કે તે વપરાશકર્તાઓને એવી વસ્તુઓ કરવા માટે સક્ષમ બનાવી શકે છે જે તેઓ કરવા સક્ષમ ન હોવા જોઈએ. ઉદાહરણ તરીકે, જો વપરાશકર્તા પાસે પોસ્ટને સંપાદિત કરવાની પરવાનગી હોય, તો તેઓ તેને કાઢી નાખવામાં પણ સક્ષમ હોઈ શકે છે.

I have a problem with Django. I am using Django 1.8 and Python 3.4. I have created a superuser and staff user in my project, but the staff user is not restricting permission in django admin panel. 
I want to restrict the staff user from accessing some of the models in django admin panel, but it is not working for me, please help me out with this issue.


A:

You should add <code>is_staff = True</code> to your User model: https://docs.djangoproject.com/en/1.8/ref/contrib/admin/#django-contrib-admin-models-logentry
<blockquote>
<p>The LogEntry model has two required fields:</p>
<ul>
<li><strong><code>&lt;code&gt;user&lt;/code&gt;</code></strong>: The User that performed the action.</li>
<li><strong><code>&lt;code&gt;action_time&lt;/code&gt;</code></strong>: The timestamp of the action.</li>
</ul>
<p>[...]</p>
<p>[...] If you want to log actions performed by non-staff users, you’ll need to set <a href="https://docs.djangoproject.com/en/1.8/_modules/django/contrib/auth/#User" rel="nofollow noreferrer"><strong><em><a href="https://docs.djangoproject.com/en/1.8/_modules/" rel="nofollow noreferrer">User.<strong></strong>.is_staff</a></em></strong></a>] to True.</p>
</blockquote>

Django માં પરવાનગીઓ

Django માં પરવાનગીઓ તમારી એપ્લિકેશન સાથે કોણ શું કરી શકે તે નિયંત્રિત કરવાનો એક માર્ગ છે. તેઓ permissions.py ફાઇલમાં વ્યાખ્યાયિત કરવામાં આવ્યા છે અને પ્રતિ-વપરાશકર્તા અથવા પ્રતિ-એપ્લિકેશનના આધારે સેટ કરી શકાય છે.

પરવાનગીઓ પરવાનગી સ્તર પર સેટ કરી શકાય છે, જે કાં તો વાંચવા અથવા લખવામાં આવે છે. એક પરવાનગી સ્તર પણ બધા વપરાશકર્તાઓને, ચોક્કસ ભૂમિકામાં માત્ર વપરાશકર્તાઓને અથવા અમુક પરવાનગીઓ ધરાવતા વપરાશકર્તાઓને મંજૂરી આપવા માટે પણ સેટ કરી શકાય છે.

તમારી એપ્લિકેશન દ્વારા કરવામાં આવેલી તમામ વિનંતીઓ માટે પરવાનગીઓ સેટ કરવા માટે તમે DJANGO_SETTINGS_MODULE પર્યાવરણ વેરીએબલનો પણ ઉપયોગ કરી શકો છો.

સંબંધિત પોસ્ટ્સ:

પ્રતિક્રિયા આપો