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
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
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
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
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
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
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
7 matches
Mail list logo