Disable fields in oldforms admin using jQuery

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
Model:

class Placeholder(models.Model):
    name=models.CharField()
    description = models.CharField(blank=True, maxlength=200)
 
    class Admin:
        list_display = ('name', 'description')
        js = (
              '/appmedia/js/jquery.js',
              '/appmedia/js/placeholder.js',
              )

placeholder.js:

$(document).ready(function(){
   $('#id_name').attr("disabled", true);
});

More like this

  1. Adding buttons to submit line in a Admin page by marinho 5 years ago
  2. Orderable inlines using drag and drop with jQuery UI by simon 4 years, 8 months ago
  3. Admin Input Field Character Count via jQuery by joshman 4 years, 5 months ago
  4. jQuery Double Click Edit ManyToMany in Admin by justhamade 3 years, 3 months ago
  5. Drag and drop ordering of admin list elements using jQuery UI by johj 2 years, 11 months ago

Comments

miguelvel18 (on October 8, 2009):

when the field is disabled,web form shows a error message of validation because the field is required. The field have a default value, but shows a error message validation, help me

#

(Forgotten your password?)