-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes: #17360 - Ensure model is defined when rendering bulk_edit_button #17535
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is the correct fix (or might be a partial fix) as I think it might just be masking the underlying issue - if you do the scenario to go to the interface and then click the edit bulk edit button (without having any items selected) you are presented with an empty page instead of a toast as you are without HTMX navigation enabled and I think it might be because of this this change allowing a blank model.
I think (not sure) that we need to find why model isn't getting set and get it set correctly.
Yeah, agreed -- this didn't really sit right with me except as a one-liner noninvasive fix. I don't yet quite understand what the underlying issue is or whether model is even supposed to be present, but I'll set this to Draft and keep digging. |
@arthanson I think the blank page on "no interfaces selected" condition is a separate issue entirely; it has to do with the fact that it's an HTMX request that encounters an error and then gets a
To deal with the immediate issue, I've reverted the change to the template and set |
Note that the surface-level error ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The template htmx/table.html
is used in several places; this needs to be addressed in all of them. It's probably sufficient to tweak the template to pass object
to the bulk action button tags, rather than model
.
All the other occurrences of |
Passing |
…g bulk_edit_button (netbox-community#17535) * Ensure model is defined when rendering bulk_edit_button * Move model check to inner conditional * Set model in context * Return child_model instead of model for use in bulk_edit_button
Fixes: #17360
Addresses a common issue in HTMX navigation where the inclusion of a call to
bulk_edit_button
where the parammodel
is a string raises anAttributeError: 'str' object has no attribute '_meta'
.This fix adds a check for truthiness of
model
before trying to render{% bulk_edit_button %}
or{% bulk_delete_button %}
intable.py
.