📜 ⬆️ ⬇️

jQuery in administration

Translation of jQuery in the admin publication with DjangoAdvent


The r12297 updates caused a real sensation: a new file appeared in the django/contrib/admin/media/js jquery.js called jquery.js . In Django administration, this change represents the beginning of a new era, an era of fashionable features, beautiful widgets and improved usability.

Arguments for jQuery


Despite the fact that the integration of the jQuery library into the administration was discussed earlier, it was seriously considered only this summer in connection with the GSoC participant’s proposal to improve the administration interface, suggesting some powerful interface functions that would be difficult to implement without using the framework.

The need for a Javascript framework in administration is hard to underestimate. Raw Javascript in any decent-sized project is gradually approaching the scope and complexity of the framework. This is a real minefield where you are dealing with cross-browser problems, “patches” and normalization; The framework removes these difficulties, allowing developers to focus on building cool pieces. We are moving forward all the time, and today there is simply no sufficient reason to write Javascript directly in the DOM API, when instead you can add useful functionality (with fewer bugs).
weebly reliable statistics
')
It is also easy to understand why jQuery is the most preferred framework: this library won a landslide victory in the JS framework war. jQuery uses almost 30% of sites monitored by builtwith.com . Choosing another library will indicate less competent developers, less accessible code and a small support community.

It does not mean that Django promotes jQuery


There is some concern in the community that the implementation of jQuery is the promotion of one framework by another, and this is not at all the case.

Actually Django remains independent of the choice of tools. Administration is an optional application created for end users, not for developers. Administration tools do not affect the content manager, and the developers are also not limited to it.

If you modify the administration of Django, jQuery will absolutely not bother you. For example, to prevent the $ function from taking up the namespace, administration uses jQuery.noConflict() , therefore, you can use $() from Prototype in your personal widgets without conflicts. Also, jQuery is loaded only on those pages where there are widgets that use it.

Your applications, as before, can use what seems more appropriate to you. As for the administration of Django, it is even more reasonable to include a proven, reliable framework than adding buggy Javascript libraries with incomplete documentation.

Django administration will now develop much faster.


The front-end administration interface is a bit stagnant, so it needs advanced advanced features, namely jQuery, the new “King of Design” , and a common community focus on improved usability.

Django version 1.2 is mainly focused on preparing the foundation for future administration interface improvements, with the most notable changes starting to appear only in Django 1.3 and later versions. However, some things really worked out.

New features


One of the first features of jQuery in administration is the dynamic addition of new strings. To familiarize yourself with this opportunity, watch the following video:



Many of the developed functions did not fall into Django 1.2, for example, changing the model-inlines order from the order-field by dragging, as well as the auto-fill widget for the Foreign Key and M2M links instead of the drop-down menu (or raw_id_fields). Most likely, these and other features will appear in Django 1.3.

It's a great time for Django administration users. Many luxury features are already available in version 1.2, and at the time of release 1.3 these features will become even more. Largely thanks to jQuery!

Previous translations with DjangoAdvent :

Source: https://habr.com/ru/post/118193/


All Articles