Solved: hindi nililimitahan ng user ng staff ang pahintulot sa django

Ang pangunahing problema sa hindi paghihigpit sa pahintulot ay maaari itong humantong sa mga user na magawa ang mga bagay na hindi nila dapat gawin. Halimbawa, kung may pahintulot ang isang user na mag-edit ng post, maaari rin nilang tanggalin ito.

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>

Mga pahintulot sa Django

Ang mga pahintulot sa Django ay isang paraan upang makontrol kung sino ang maaaring gumawa ng kung ano sa iyong app. Ang mga ito ay tinukoy sa permissions.py file at maaaring itakda sa bawat user o per-app na batayan.

Maaaring itakda ang mga pahintulot sa antas ng pahintulot, na maaaring basahin o isulat. Ang antas ng pahintulot ay maaari ding itakda upang payagan ang lahat ng user, ang mga user lamang sa isang partikular na tungkulin, o ang mga user lamang na may ilang partikular na pahintulot.

Maaari mo ring gamitin ang DJANGO_SETTINGS_MODULE environment variable upang magtakda ng mga pahintulot para sa lahat ng kahilingang ginawa ng iyong app.

Kaugnay na mga post:

Mag-iwan ng komento