Answer the question
In order to leave comments, you need to log in
How to fix bug in Django - add_view?
There are 2 groups of users: sellers, store director
Well, and superadmin, who sees everything and can edit everything.
For the seller , when adding a record, certain fields are hidden, the same for the director .
Here is the code:
def add_view(self, request, form_url='', extra_context=None):
if not request.user.is_superuser:
if request.user.groups.all()[0].id == 2:
self.exclude=('date_job', 'text_job', 'vendors_response', 'solution', 'response_buyer', 'status', 'user', 'shop')
elif request.user.groups.all()[0].id == 4:
self.exclude=('date_job', 'text_job', 'vendors_response', 'solution', 'response_buyer', 'status', 'user')
else:
self.exclude=('date_job')
return super(ClaimAdmin, self).add_view(request, form_url='', extra_context=None)
Answer the question
In order to leave comments, you need to log in
exclude is a class field, not an object. In __init__ of the view write self.exclude = None
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question