Aramgutang,

> Currently, it is unclear as to how apps that override admin templates
> should maintain compatibility with both 1.3 and 1.4 when referring to
> the admin media file URLs in the overridden templates. This applies
> primarily to third-party apps like django-admin-tools, that want to
> support at least the latest two major Django versions.
> 
> The changes I'm referring to are ones in the giant r16487 commit
> ( 
> https://github.com/django/django/commit/09cccc395597145d35f3793d57f70b7795214f64
> ).
> 
> Since that change, Django now constructs URLs using `{% static "admin/
> css/base.css" %}` internally, instead of the old `{%
> admin_media_prefix %}css/base.css` method. That change also saw the
> removal of `ADMIN_MEDIA_PREFIX = '/static/admin/'` from
> djago.conf.global_settings. This results in the following dilemma for
> any app that wishes to maintain compatibility with both 1.3 and 1.4:
> 
> To maintain support for 1.3, the app cannot use {% static %}, as it is
> not available yet, so it uses {% admin_media_prefix %}, which causes a
> PendingDeprecationWarning that we're OK to ignore. However, due to the
> removal of the default ADMIN_MEDIA_PREFIX value, the {%
> admin_media_prefix %} tag no longer works as expected, returning "css/
> base.css" instead of "/static/css/base.css". To overcome this, the app
> needs to ask that the project define an ADMIN_MEDIA_PREFIX, or define
> one itself, nether of which is desirable. Furthermore, having an
> ADMIN_MEDIA_PREFIX defined now triggers a DeprecationWarning, which is
> visible, and we're not OK to ignore it anymore.

I think that's not a dilemma at all, Django 1.3 requires setting
ADMIN_MEDIA_PREFIX to an appropriate value as before. But you probably
want to prepare your user to remove it at some point (once they upgrade
to 1.4.X) to prevent any deprecation warnings. Feel free to point to the
1.4 release notes.

Also, as a hint to your users, I recommend to raise an ImproperlyConfigured
exception in your own app (e.g. in the management or models module) if
django.VERSION is lower than 1.4 and no `ADMIN_MEDIA_PREFIX` is specified. 

> Of course, the app can provide its own {% admin_media_prefix %} tag,
> where it checks for ADMIN_MEDIA_PREFIX first, and returns STATIC_URL/
> admin if it's not found, but this seems like the kind of functionality
> that should be provided by Django itself, to reduce the number of apps
> that will break with the upgrade to 1.4.

A certain level of migration is expected (hence the deprecation warnings),
so it'd be best to include setup instructions in your app's documentation.

> I'm happy to write a ticket and a patch, but just wanted to hear from
> the core devs' opinion on the issue first.

IMO, there is no need for a ticket or patch as this isn't a bug, Django
needs to move away from special casing the admin, now that we have a
general solution with `staticfiles`. Can you elaborate what you had in
mind?

Jannis

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to