Re: How to allow user only update who belong to that post ?

2022-04-07 Thread Lakshyaraj Dash X-D 25
Just try out the lines below if request.user.is_authenticated: user = request.user if (post.author.username == user): # your code here else: # show yor error that you cannot edit other user's post else: return redirect ("/") On Thu, Apr 7, 2022, 23:14 Kasper

Re: How to allow user only update who belong to that post ?

2022-04-07 Thread Kasper Laudrup
On 07/04/2022 09.57, OG TV wrote: Hello everybody Please kindly help me out for my Django project I try to update the post from the specific admin but even i'm not belong to that post but  i'm still can update that post so the point is I want to allow user can only update the post who belong to

Re: How to allow user only update who belong to that post ?

2022-04-07 Thread John Dollosa
Oh sorry this example is for DRF On Thursday, 7 April 2022 at 21:26:23 UTC+8 John Dollosa wrote: > Hello! > > I have a similar requirement from my project and heres what I did. > > 1. First you need to create a permissions.py file which contains a class > > Here is a sample code snippet. > > cl

Re: How to allow user only update who belong to that post ?

2022-04-07 Thread John Dollosa
Hello! I have a similar requirement from my project and heres what I did. 1. First you need to create a permissions.py file which contains a class Here is a sample code snippet. class UpdateOwnPost(permissions.BasePermission): """Allow user to edit their own project""" def has_object_permissi

How to allow user only update who belong to that post ?

2022-04-07 Thread OG TV
Hello everybody Please kindly help me out for my Django project I try to update the post from the specific admin but even i'm not belong to that post but i'm still can update that post so the point is I want to allow user can only update the post who belong to that post I meant who own that po

Re: TypeError: Cannot call delete() after .distinct() in the Admin

2022-04-07 Thread Mike Dewhirst
Sorry - just found it in the docs M On 7/04/2022 5:05 pm, Mike Dewhirst wrote: How can I remove the 'Delete' option from Django Admin actions? Many thanks Mike -- Signed email is an absolute defence against phishing. This email has been signed with my private key. If you import my public

TypeError: Cannot call delete() after .distinct() in the Admin

2022-04-07 Thread Mike Dewhirst
How can I remove the 'Delete' option from Django Admin actions? Many thanks Mike -- Signed email is an absolute defence against phishing. This email has been signed with my private key. If you import my public key you can automatically decrypt my signature and be sure it came from me. Just ask