KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I've tried various methods to achieve this. I decided against overriding formfield_for_dbfield as it doesn't get a copy of the request object and I was hoping to avoid the thread_locals hack. I settled on overriding get_form in my ModelAdmin class and tried the following: class PageOptions(admin.ModelAdmin): def get_form(self, request, obj=None, **kwargs): if request.user.is_superuser: self.fieldsets = ((None, {'fields': ('title','name',),}),) else: self.fieldsets = ((None, {'fields': ('title',),}),) return super(PageOptions,self).get_form(request, obj=None, **kwargs) When I print fieldsets or declared_fieldsets from within get_form I get None (or whatever I set as an initial value in PageOptions ). Why doesn't this work and is there a better way to do this?
Tags (comma-separated)
Save Edits
Cancel