Edc custom django ModelAdmin mixins, tags and templates
Overrides ModelAdmin's get_form
to insert question numbers and the DB field names.
Skips the changelist
and redirects to the next CRF or Requisition listed in an edc visit schedule if "[Save and Next]" is clicked instead of "[SAVE]"
class BaseModelAdmin:
search_fields = ("subject_identifier",)
add_form_template = "edc_model_admin/admin/change_form.html"
change_form_template = "edc_model_admin/admin/change_form.html"
change_list_template = "edc_model_admin/admin/change_list.html"
@admin.register(CrfTwo)
class CrfTwoAdmin(BaseModelAdmin, ModelAdminNextUrlRedirectMixin, admin.ModelAdmin):
show_save_next = True
show_cancel = True
You need to use the included change_form.html
to override the submit buttons on the admin
form.
See also:: edc_visit_schedule
Redirects the admin form on save to a view other than the default changelist
if post_url_on_delete_name
is set.
You can also store url names in the request object if used together with the Middleware from edc_dashboard
and edc_subject_dashboard
. This is useful if you do not know the namespace until deployment.
For example, add to settings:
and then declare the model admin class:
ModelAdminRedirectOnDeleteMixin
will attempt to get the urlname from the request object using post_url_on_delete_name
as a dictionary key.