Answer the question
In order to leave comments, you need to log in
Display field depending on user status, how?
I have a model
class CompanyNews(models.Model):
...
IsVisible = models.BooleanField(default=False)
IsVisible
in the admin panel visible only to the superuser, how to do this? get_queryset
in admin.py, but I don't know, somehow there is not enough experience yet. Answer the question
In order to leave comments, you need to log in
You need to override the get_fields method :
@admin.register(CompanyNews)
class CompanyNewsAdmin(admin.ModelAdmin):
...
def get_fields(self, request, obj=None):
fields = super(StudentAdmin, self).get_fields(request, obj)
if not request.user.is_superuser:
fields.remove('IsVisible')
return fields
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question