I have a profile model with a 121 to user. I want users to be able to log in to admin and view and edit only their profile instance.
Thank you.
I have a profile model with a 121 to user. I want users to be able to log in to admin and view and edit only their profile instance.
Thank you.
First thing if you want your site users to be able to log in to django admin than you have to make is_staff for every user to True as only staff and superuser is able to log in through django admin.
After that create custom permission according to your need and assign that permission to each user while creating them, by having certain permission the staff user is only able to do that task which your permission allows them.
Although I don’t really use Django admin to allow any user to do such user related thing instead I would have created separate template to do such thing with DTL, but it’s your choice how you want it done
@rahlok - Since you’re asking for the “Preferred way” to do this, I’m going to direct you to the Django documentation to say that the best / preferred way to do this is to not use the admin for this purpose.
See The Django admin site | Django documentation | Django
The admin’s recommended use is limited to an organization’s internal management tool.
Do yourself a favor and build a simple view to allow users to update their profile. It’s not much more work than trying to get the admin to do this, and it will be a lot more secure.
Thanks @KenWhitesell sir for clearing this