Code

Ticket #10573: 10573_r12827_with_fields.diff

File 10573_r12827_with_fields.diff, 784 bytes (added by copelco, 4 years ago)

alternative patch if #12627 is closed

Line 
1Index: django/contrib/admin/templates/admin/change_form.html
2===================================================================
3--- django/contrib/admin/templates/admin/change_form.html       (revision 12827)
4+++ django/contrib/admin/templates/admin/change_form.html       (working copy)
5@@ -55,8 +55,14 @@
6 
7 {% submit_row %}
8 
9-{% if adminform and add %}
10-   <script type="text/javascript">document.getElementById("{{ adminform.first_field.auto_id }}").focus();</script>
11+{% if adminform and add and adminform.form.fields %}
12+    <script type="text/javascript">
13+    (function($) {
14+        $(document).ready(function($) {
15+            $("input:visible:enabled:first").focus();
16+        });
17+    })(jQuery.noConflict());
18+    </script>
19 {% endif %}
20 
21 {# JavaScript for prepopulated fields #}