djongo
djongo copied to clipboard
How to make a field in ArrayModelField readonly in Django admin page?
The document didn't specify how to make the fields in abstract model readonly in Django's admin.
Python script
For example, I have two models as shown below:
class MyNestedModel(models.Model):
class Meta:
abstract = True
field_2 = models.CharField(max_length=20, default='', blank=True)
class MyModel(models.Model):
field_1 = models.ArrayModelField(
model_container=MyNestedModel,
model_form_class=MyNestedForm,
default=[]
)
How could I make field_2
readonly in Django's admin page?
For fields in MyModel
, we can just do the settings in admin.py
:
class MyModelAdmin(admin.ModelAdmin):
readonly_fields = ['...']
Is there any similar way for the abstract model?
Thank you.
+1
I also need this feature
+1