Repository: wagtail/wagtail

Issue:
Generic view method `DeleteView.get_delete_view` looks for wrong url name
<!--
Found a bug? Please fill out the sections below. 👍
-->

### Issue Summary

This looks to me like a one line typo bug:

In `wagtail/admin/views/generic/models.py`: 
- Link [here](https://github.com/wagtail/wagtail/blob/fb4837371f8e1bddd5c97bf5c0b8268765845911/wagtail/admin/views/generic/models.py#L654)

`DeleteView` is checking if the subclass has defined `self.index_url_name`. But given the wider context and the error message in the `ImproperlyConfigured` exception, it should surely be checking if `self.delete_url_name` is None.

```python
class DeleteView(.....):
    # Other code in class not reproduced for brevity.

    delete_url_name = None

    def get_delete_url(self):
        if not self.index_url_name:  # <----- Should this perhaps be `self.delete_url_name`?
            raise ImproperlyConfigured(
                "Subclasses of wagtail.admin.views.generic.models.DeleteView must provide a "
                "delete_url_name attribute or a get_delete_url method". # <-- Note that delete_url_name is referenced here
            )
        return reverse(self.delete_url_name, args=(quote(self.object.pk),))

```

### Steps to Reproduce

[Here is a link](https://github.com/wagtail/wagtail/blob/fb4837371f8e1bddd5c97bf5c0b8268765845911/wagtail/admin/views/generic/models.py#L654) to the source code reproduced above. 

1. Create a new wagtail project with a django model
2. Subclass `DeleteView` to make a view for deleting instances of your model.
3. Override `get_successs_url` so it isn't dependent on `index_url_name`.
4. Define a suitable `delete_url_name` (it can be the name of the url of the view itself as it is used as the confirm_delete.html form tag action url.
5. Do not define `index_url_name`.

At this point your view should be valid. You haven't defined index_url_name but then you shouldn't have code that depends on it as you have provided your own `get_success_url`.

However, your view will raise ImproperlyConfigured and Wagtail will tell you that DeleteView must define `delete_url_name`.

What has gone wrong is that Wagtail has actually checked if you have defined `index_url_name` (which you haven't) even though it should be checking for `delete_url_name`

Any other relevant information. For example, why do you consider this a bug and what did you expect to happen instead?

-   I have confirmed that this issue can be reproduced as described on a fresh Wagtail project: yes

### Technical details

-   Python version: 3.10
-   Django version: 4.1
-   Wagtail version: 4.1.1
-   Browser version: Chrome 108



Discussion:
Thanks for the report @alexalligator! Yep, that definitely looks like a bad copy-and-paste in https://github.com/wagtail/wagtail/commit/45ac80bb8994dafe62e090c658030fe4438ff0b6.

Resolving patch:
diff --git a/wagtail/admin/views/generic/models.py b/wagtail/admin/views/generic/models.py
--- a/wagtail/admin/views/generic/models.py
+++ b/wagtail/admin/views/generic/models.py
@@ -652,7 +652,7 @@ def get_page_subtitle(self):
         return str(self.object)
 
     def get_delete_url(self):
-        if not self.index_url_name:
+        if not self.delete_url_name:
             raise ImproperlyConfigured(
                 "Subclasses of wagtail.admin.views.generic.models.DeleteView must provide a "
                 "delete_url_name attribute or a get_delete_url method"


Test patch: