Reputation: 319
I want the user can edit their own profile, but can't edit other user's, how to make this kind of restriction in Django?
@login_required
def edit_profile:
# some check
pass
Upvotes: 0
Views: 801
Reputation: 45575
You don't need any restriction. Just get the profile of the logged user and edit it:
@login_required
def edit_profile(request):
profile = request.user.profile
...
Upvotes: 4