Hello, I would like to use Django Admin features to enable site admins manipulate with models. But some of my models contain fields/attributes which have specific logic to be done before the value for the field can be generated.
For example I have model CalendarEvent
which has attribute recurrence_pattern
which is type of CharField
. Before the recurrence_pattern
can be set it must be determined by using combination of several texboxes, checkboxes and radiobuttons.
So I have to provide this textboxes, checkboxes and radiobuttons within the form and then using specific logic populate recurrence_pattern
.
Is that possible to do using Django Admin ?
So it is not enough to specify recurrence_pattern
within the fields
because then just the regular textbox will be shown - but I have to extend this. How to do that ? Could you point me to some examples of documentation (in the Django documentation I did not find such examples) ?
Yes, Django provides the facility for overriding a form in the admin.
See ModelAdmin.form for a starting point, but it’s also worth reviewing all of ModelAdmin to see what other options may be available.
Ken
1 Like