Document/Images Usage page: 'ManyToOneRel' object has no attribute 'verbose_name’ #11482
Labels
status:Unconfirmed
Issue, usually a bug, that has not yet been validated as a confirmed problem.
type:Bug
Issue Summary
Users cannot view the usage details of documents or images (where they’re being used) used at least once in any multiple Parentalkey levels models from the Wagtail admin site.
When images/documents are used in certain parts of the website, and users try to get the usage information on where those images/documents are being used at, the following error occurs at trying to get the
verbose_name
from the right child field (determined through the reference index):This seems to be a problem in referencing the
verbose_name
of the correct child field, likely stemming from the multiple ParentalKey level nested structure of the ClusterableModel/Orderable models in the example (Resource → ResourceGroup → ResourceItem, etc.).Affected Code:
wagtail/wagtail/models/reference_index.py
Lines 651 to 653 in ef9375c
Current Expected:
ManyToOneRel
→ Child Field withverbose_name
(Image/Document)Actual:
ManyToOneRel
→ManyToOneRel
→ Child Field withverbose_name
(Image/Document)Ultimately, we might be looking at a recursive fix for multi-level ManyToOneRel fields.
Video demonstrating the issue (Steps 6 to 10 in Steps to Reproduce below):
https://www.loom.com/share/8dade8f9e25e44c38b4a863c870d8098?sid=bf96dd4a-0b96-4413-8e89-47e201b88808
Steps to Reproduce
Start a fresh Wagtail project following the tutorial at https://docs.wagtail.org/en/stable/getting_started/tutorial.html up until the Start the server step.
Replace the contents of
mysite/home/models.py
with the following code:Create a
wagtail_hooks.py
file at themysite/home
directory with the following contents:On your terminal, run
python manage.py makemigrations
thenpython manage.py migrate
from the project root directory (eg.../mysite
)Browse and login to the Wagtail Admin site at
localhost:8000/admin
with your admin account.Using the sidebar, navigate to Snippets → Resources.
Perform the following: Add resource → Add resource group → Add resource (Under Resource Group 1) → Choose a document (Upload any file) → Save
Once the new Resource object is created, using the sidebar, navigate to Documents and select the document you just uploaded.
On the right/bottom of the page, under Usage, select Used 1 time
The following error should occur:
Expected Outcome:
No errors occur, and the usage page of the selected document can be viewed, with the correct
verbose_name
of field references listed under theField
column. e.g. Resource group → Resource item → DocumentTechnical details
3.8.14
3.2.23
5.2.2
Working on this
I'm keen to work on this issue once it has been accepted.
The text was updated successfully, but these errors were encountered: