Changes between Version 60 and Version 61 of NewformsAdminBranch


Ignore:
Timestamp:
Jul 9, 2008, 1:06:01 PM (16 years ago)
Author:
Brian Rosner
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • NewformsAdminBranch

    v60 v61  
    264264See [http://code.djangoproject.com/browser/django/branches/newforms-admin/docs/admin.txt#L506 this documentation] for more details on field options for inline classes
    265265
     266=== Refactored inner Admin ```js``` option to media definitions ===
     267
     268In [5926] a new method of dealing with media definitions was added. It is now
     269much more flexible and allows media on more than just a {{{ModelAdmin}}}
     270classes.
     271
     272An example:
     273{{{
     274#!python
     275
     276# OLD:
     277class MyModel(models.Model):
     278    # not relavent, but here for show
     279    field1 = models.CharField(max_length=100)
     280   
     281    class Admin:
     282        js = (
     283            "/static/my_code.js",
     284        )
     285
     286# NEW:
     287# in admin.py
     288
     289class MyModelAdmin(admin.ModelAdmin):
     290    class Media:
     291        js = (
     292            "/static/my_code.js",
     293        )
     294}}}
     295
     296One very subtle thing to note is previously with trunk the documentation stated:
     297
     298    If you use relative URLs — URLs that don’t start with {{{http://}}} or {{{/}}} — then the admin site will automatically prefix these links with {{{settings.ADMIN_MEDIA_PREFIX}}}.
     299
     300Which is still partially true with newforms-admin, but now when using relative URLs {{{settings.MEDIA_URL}}} is prepended and '''not''' {{{settings.ADMIN_MEDIA_PREFIX}}}. If you are still looking for the old behavior you can accomplish it by doing the following:
     301
     302{{{
     303#!python
     304
     305from django.conf import settings
     306
     307class MyModelAdmin(admin.ModelAdmin):
     308    class Media:
     309        js = (
     310            settings.ADMIN_MEDIA_PREFIX + "some_file.js",
     311        )
     312}}}
     313
     314Make sure the value of {{{settings.ADMIN_MEDIA_PREFIX}}} is a proper absolute URL otherwise it will be treated the same as a relative URL.
     315
    266316=== Moved raw_id_admin from the model definition ===
    267317
Back to Top