[Django]-Linking directly to Wagtail modeladmin views

10👍

The URL name will be of the following form, where [action] is one of index, create, edit, delete, inspect or choose_parent:

[app_label]_[model_name]_modeladmin_[action]

For example:

  • {% url 'directory_organisation_modeladmin_index' %}
  • {% url 'directory_organisation_modeladmin_create' %}
  • {% url 'directory_organisation_modeladmin_edit' instance_pk=37 %}
  • {% url 'directory_organisation_modeladmin_delete' instance_pk=37 %}
  • {% url 'directory_organisation_modeladmin_inspect' instance_pk=37 %}
  • {% url 'directory_organisation_modeladmin_choose_parent' %}

Since the URLConf provided doesn’t contain a namespace argement to include(), no namespace is required.

Similar to Django’s built-in Admin, Wagtail generates these URLs dynamically in the ModelAdmin.get_admin_urls_for_registration() with some helpers like AdminURLHelper.get_action_url_name().

Leave a comment