Why jQuery shouldn't be in the (Django) admin
lazypython.blogspot.com
lazypython.blogspot.com
My guess is that it's the empty set. If you can pick up arbitrary custom Javascript, you can probably pick up jQuery pretty quickly, too. Even I know jQuery...
I'm kinda on the fence about contrib.admin bundling/using jQuery, but not for any of the reasons in this article. For me it comes down entirely to compatibility.
At my day job I work with the oldest Django codebase in the world, and also one of the largest. We do pretty much everything it's possible to do with Django, including some fairly heavy custom admin stuff. Quite a bit of that involves JavaScript.
At the moment, we have code actively using the current bundled admin JS, two different public JS frameworks and one private internal JS framework. This is the result of years of dev work making use of whatever tools we happened to be using at the moment, and all of it still works today; we even have areas where multiple JS frameworks are in use side-by-side on the same page along with reuse of the standard admin JS.
I simply don't know what happens to all that code if suddenly the admin is jQuery. I don't know off the top of my head all the possible intersections of libraries and frameworks and how much code would need to be rewritten as a result. And I really don't want to think about whether people who use, say, MooTools for their own customizations would suddenly get the rug pulled out from under them (if Django's bundled jQuery and your bundled MooTools each want to bind '$', who wins?).
If the admin's going to move to using jQuery, these are the sorts of questions which need to be thought out, planned for and answered very, very thoroughly first.
Yep. There needs to be a migration plan:
1. Announce that jQuery will temporarily use '$djq' (Django's jQuery) for jQuery starting in a few months. Don't let anything using '$' be committed during the migration period.
2. Immediately add JavaScript code to the bottom of every admin page that checks for the existence of '$djq'. If it is present, put a big flashing warning message on the page that says "Your Django admin page may break soon. Have your sysadmin look at this page [link goes here]."
3. The poor fools using '$djq' get a short chance to migrate their code. Probably nobody is using it anyway.
4. Start using '$djq'. You don't want to do this forever because it will confuse all the novices reading the jQuery tutorials and books.
5. Announce that the Django admin will switch to '$' for jQuery at the Django 1.1.0 release. (Or 1.2.0 if 1.1.0 is too soon.) '$djq' will be permanently left as an alias for '$', for compatibility with local admin code written during the migration period.
6. Put JavaScript code at the bottom of each admin page that checks if '$' is not jQuery and puts a giant blinking warning at the bottom of the admin page. Have a settings.py option to turn off the warning once the sysadmins learn what is going on. If somebody turns it off and doesn't develop a migration plan, that's their fault.
7. Shortly before 1.1.0, put in a new flashing warning that can't be turned off.
8. Substitute '$' for '$djq' for the pre-1.1.0 releases.
If you want to write raw javascript against the metal and want it to be in any kind of usable state, the person writing it would have to be very familiar with cross-platform issues and quirks in various browsers and be able to route around them. In other words, they would have to, by defintion, be good enough to implement their own javascript framework.
Saying that using a framework which already handles this and is popular, standardized and free (as in speech) will increase the barrier for contribution is just plain misguided.
2) kind of seems ironic that someone thinks that django, a development framework, should be against using a development framework because of the nature of frameworks.