Rectangle 27 0

Django ModelChoiceField not adding attrs to html in admin?


if not self.instance.is_virtual:
        ServerAdminForm.host = django.db.models.ForeignKey(u'self', blank=True, null=True)
        ServerAdminForm.base_fields['host'] = ServerAdminForm.host

If not, you can create or modify your form dynamically using base_fields in __init__:

If you want to toggle the field display on click, you should use javascript. See: How To Collapse Just One Field in Django Admin?

Thanks. I will look into that tomorrow when I get to work. Any ideas on why the html of the field does not have the attributes disabled or readonly?

The javascript method worked great, Thanks. I am still curious why my above approach was failing though.

Note