I have a question regarding admin customization
For example I have a following model with m2m on itself via through model
class Company(models.Model):
some fields here…
more fields …
known_carriers = models.ManyToManyField(
"self",
through=’OtherModel’,
through_fields=('field1', 'field2'),
related_name='known_customers',
symmetrical=False,
)
and admin on this model
@admin.register(models.Company)
class CompanyAdmin(admin.ModelAdmin):
…
…
filter_horizontal = (
...
'known_carriers',
...
)
…
...
known_carriers
in this admin is rendered as a nice widget specifying on a left side list of available model instances to add to m2m and on a right side ones have already added.
Question is – is it possible to render same widget in admin but disabled, that is without possibility to move elements from left to right side and in opposite direction by mouse click or by clicking on arrows. Only nice representation is needed.
Thank you.
P.S. adding it to readonly_fields
basically changes widget to SelectMultiple
(with different simple layout), so this is not an option.