সমাধান করা হয়েছে: স্টাফ ব্যবহারকারী জ্যাঙ্গোতে অনুমতি সীমাবদ্ধ করছে না

অনুমতি সীমাবদ্ধ না করার প্রধান সমস্যা হল এটি ব্যবহারকারীদের এমন কিছু করতে সক্ষম হতে পারে যা তাদের করা উচিত নয়। উদাহরণস্বরূপ, যদি একজন ব্যবহারকারীর একটি পোস্ট সম্পাদনা করার অনুমতি থাকে তবে তারা এটি মুছে ফেলতেও সক্ষম হতে পারে।

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>

জ্যাঙ্গোতে অনুমতি

জ্যাঙ্গোতে অনুমতি হল আপনার অ্যাপের মাধ্যমে কে কী করতে পারে তা নিয়ন্ত্রণ করার একটি উপায়। সেগুলি permissions.py ফাইলে সংজ্ঞায়িত করা হয়েছে এবং প্রতি-ব্যবহারকারী বা প্রতি-অ্যাপ ভিত্তিতে সেট করা যেতে পারে।

অনুমতি একটি অনুমতি স্তরে সেট করা যেতে পারে, যা হয় পড়া বা লিখতে হয়। একটি অনুমতি স্তরও সমস্ত ব্যবহারকারীদের, শুধুমাত্র একটি নির্দিষ্ট ভূমিকায় থাকা ব্যবহারকারীদের, অথবা শুধুমাত্র নির্দিষ্ট অনুমতি সহ ব্যবহারকারীদের অনুমতি দেওয়ার জন্য সেট করা যেতে পারে।

আপনি আপনার অ্যাপ দ্বারা করা সমস্ত অনুরোধের জন্য অনুমতি সেট করতে DJANGO_SETTINGS_MODULE পরিবেশ পরিবর্তনশীল ব্যবহার করতে পারেন।

সম্পর্কিত পোস্ট:

মতামত দিন