#admin.site.register(Poll) first generation answer
class PollAdmin(admin.ModelAdmin):
fields = ['pub_date', 'question']
admin.site.register(Poll, PollAdmin)
lets say we want to collapse some of the fields to make them easier to manage.
we can do this by altering the code like so go to your admin.py file and change the fields so they read
class PollAdmin(admin.ModelAdmin): fieldsets = [ (None, {'fields': ['question']}), ('Date information', {'fields': ['pub_date'], 'classes': ['collapse']}), ]
if we exam the code we can see that we have the date field like before but we have added
classes : ['collapse']


No comments:
Post a Comment