Answer the question
In order to leave comments, you need to log in
How to tweak the admin?
I have some report of logs of actions of the user. And in fact, I don’t need the ability to add a new log through the admin panel and edit existing ones. How to implement it? That is, remove the ability to add and update the model through the admin panel?
Answer the question
In order to leave comments, you need to log in
Can you see these models?
class MyAdmin(admin.ModelAdmin):
fields = ['name', 'slug', 'date']
readonly_fields = ['date']
def has_add_permission(self):
# Убрать право добавлять новые элементы
return False
def get_readonly_fields(self, request, obj=None):
if obj and obj.pk:
return self.fields
else:
return self.readonly_fields
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question