Changes between Version 1 and Version 2 of DjangoSpecifications/NfAdmin/MediaAndValidation


Ignore:
Timestamp:
Mar 20, 2008, 6:53:14 AM (17 years ago)
Author:
mrts
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DjangoSpecifications/NfAdmin/MediaAndValidation

    v1 v2  
     1''Part of DjangoSpecifications''
     2
    13= Media and validation in newforms-admin =
    24
    3 Attaching media (especially JavaScript) and custom validation is a common use case for admin section. It should be easy.
     5Attaching media (especially !JavaScript) and custom validation is a common use case for admin section. It should be easy.
     6
     7Currently, `get_form()` can be used to provide a custom form that can bring in !JavaScript and custom validation. But once this method is overriden, your form will not automatically get the custom admin widgets. As the automatic widgets are the main point of using admin, this is not generally acceptable.
     8
     9== Proposal ==
     10
     11Customizing the admin should be possible by specifying an extension form for the admin class, preferrably with a class field: `class FooAdmin(admin.ModelAdmin): admin_form = FooAdminForm`. Overriding `get_form()` is equally acceptable.
     12
     13 * Specifying this custom form should not disable automatic widgets
     14 * !JavaScript, CSS and whatnot should be merged from the inner Media class if it is present in the custom form: `class FooAdminForm(forms.BaseForm): media = forms.Media(js = ['/site_media/js/tiny_mce/tiny_mce.js'])`
     15 * Custom validation should be possible with the ordinary `clean_field()` and `clean()` overrides in the custom form.
     16
Back to Top