blog posts

databases (1) django (1) drupal (2) java (4) processing (7) wamp (1) yahoo pipes (1)

Monday, 10 January 2011

Django for Windows 7 editing poll options

We saw in the last tutorial how to setup polls in django. The code that is listen below shows quite clearly show are initial code which is commented out and beneath this the new code this alters the order of the poll.  
#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

Popular Posts