Changes between Version 39 and Version 40 of NewformsHOWTO


Ignore:
Timestamp:
07/14/2008 03:45:57 PM (7 years ago)
Author:
Martin Diers <martin@…>
Comment:

Updated custom CSS and JS section to use Media class directly in ModelAdmin class.

Legend:

Unmodified
Added
Removed
Modified
  • NewformsHOWTO

    v39 v40  
    505505== Q: How do I add custom !JavaScript/CSS? ==
    506506
    507 Since changeset [7365] you can pass a media definition to the ModelForm, eg:
    508 
    509 {{{
    510 #!python
    511 class PageFormWithMedia(forms.ModelForm):
     507Just pass a media definition to ModelAdmin, eg:
     508
     509{{{
     510#!python
     511
     512class PageOptions(admin.ModelAdmin):
    512513    class Media:
    513514        js = ('/some/form/javascript',)
     
    515516        'all': ('/some/form/css',)
    516517        }
    517     class Meta:
    518         model = Page
    519 
    520 class PageOptions(admin.ModelAdmin):
    521     form = PageFormWithMedia
    522518 
    523519admin.site.register(Page, PageOptions)
Back to Top