हल: कर्मचारी उपयोगकर्ता django में अनुमति को प्रतिबंधित नहीं कर रहा है

अनुमति को प्रतिबंधित न करने की मुख्य समस्या यह है कि इससे उपयोगकर्ता उन चीजों को करने में सक्षम हो सकते हैं जो उन्हें नहीं करनी चाहिए। उदाहरण के लिए, यदि किसी उपयोगकर्ता के पास किसी पोस्ट को संपादित करने की अनुमति है, तो वह उसे हटा भी सकता है।

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 पर्यावरण चर का भी उपयोग कर सकते हैं।

संबंधित पोस्ट:

एक टिप्पणी छोड़ दो