id,summary,reporter,owner,description,type,status,component,version,severity,resolution,keywords,cc,stage,has_patch,needs_docs,needs_tests,needs_better_patch,easy,ui_ux 15231,Admin DateTimeShortcuts + Inlines performance,Fabian Büchler,nobody,"In the admin, stacked or tabular inlines reinitialize the DateTimeShortcuts widgets for date or time fields whenever an inline row/form is added or removed. This has serious performance problems if your inline has a couple of date/time fields per row. About 95% of JS execution time is spent on the reinitialization of DateTimeShortcuts resulting in continious JS timeouts in even the most modern browsers. A couple of days ago I've offered to fix this in the django-devleopers list: http://groups.google.com/group/django-developers/browse_thread/thread/ff460085a3bfb12e/ I've rewritten {{{admin/DateTimeShortcuts.js}}} and {{{calendar.js}}} and combinded them in a new {{{datetimeshortcuts.js}}} (+ minified version), which is jQuery based and uses 1.4.2 event delegation. This way, inlines do not need to reinitialize the DateTimeShortcuts widgets at all. The usage of the new datetimeshortcuts.js is as follows: By default, all {{{.fieldsets}}} are dts-enabled by the following call at the bottom of {{{datetimeshortcuts.js}}} {{{ $(""fieldset.module"").datetimeshortcuts(); }}} Users can use the plugin as well, for their own fields, specifing field selectors and enabling or disabling the today, calendar, now and clock widgets separately: {{{ $('my-selector').datetimeshortcuts({ date_fields: ""input:text.date_from, input:text.date_to"", time_fields: ""input:text.time_from, input:text.time_to"", enable_calendar: true, enable_today: true, enable_clock: false, enable_now: false }); }}} In the admin's {{{base.html}}}, I've defined a basic set of options for DateTimeShortcuts, which override the default options of {{{datetimeshortcuts.js}}}: {{{ $('body').data('datetimeshortcuts_defaults', { enable_calendar: true, enable_today: true, enable_clock: true, enable_now: true }); }}} It would be great to add a variable to Django's settings to define these in your {{{settings.py}}} and include the values via a template tag in the {{{base.html}}}. I don't know if you are willing to do this, so I didn't prepare it for this patch. A patch is ready and attached. ",Cleanup/optimization,new,contrib.admin,dev,Normal,,,,Accepted,1,0,0,1,0,0