I want to hide the edit, add, and remove icons from the Django admin tool for a foreign key field.
Is it possible to achieve this? If so, how?
This is my code so far:
@admin.register(Request)
class RequestAdmin(admin.ModelAdmin):
list_display = (
"name",
"contact_method",
"neighborhood",
"adults",
"children",
"prescriptions",
"volunteer",
"status",
"due_date",
)
list_editable = ("status", "volunteer")
def neighborhood(self, obj):
if obj.address and obj.address.get("neighborhood", False):
neighborhood = obj.address["neighborhood"]
if obj.address.get("details", False):
return f"{neighborhood} - {obj.address['details']}"
return neighborhood
It seems the problem is that I have also registered another model Volunteer.
@admin.register(Volunteer)
class VolunteerAdmin(admin.ModelAdmin):
list_display = ("name", "contact_method", "neighborhood", "valid_ID")
def neighborhood(self, obj):
if obj.address and obj.address.get("neighborhood", False):
return obj.address["neighborhood"]
However, I need to keep this model too. So, how can I achieve this?


