-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closes #21209: Support real model names in configuration parameters #21275
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
base: main
Are you sure you want to change the base?
Conversation
… configuration Enable DEFAULT_DASHBOARD, CUSTOM_VALIDATORS, and PROTECTION_RULES to accept both lowercase (e.g. "dcim.site") and PascalCase (e.g. "dcim.Site") model names, providing consistency with FIELD_CHOICES. - Update get_models_from_content_types() to normalize model identifiers - Add _get_validators_for_model() helper for case-insensitive config lookup
8c77bf2 to
273750c
Compare
|
Thanks a lot for working on this! 🙌 While reviewing the feature request, I noticed the scope is a bit broader than what’s currently covered in this PR. The request is to allow ContentType/ObjectType strings (e.g.
From what I can see, this PR currently addresses only the Would you mind taking another pass to review the other config paths as well, and extend the PR to include any additional configuration options where these model strings are accepted? |
1a3a76f to
03912fc
Compare
Thanks for the review @pheus! Really appreciate it! 🙌 The PR now covers all three areas mentioned in the FR:
As a bonus, I also updated CUSTOM_VALIDATORS to use the same case-insensitive pattern for consistency. All changes follow the same approach: try an exact match first (O(1)), then fall back to a case-insensitive search if needed. This maintains backward compatibility while allowing users to use either format. The PR is ready for another review. |
Summary
This PR adds support for real model names (e.g.,
dcim.Site) inDEFAULT_DASHBOARD,CUSTOM_VALIDATORS, andPROTECTION_RULESconfiguration parameters, matching the syntax used byFIELD_CHOICES.Changes:
normalize_model_identifier()utility function to convert real model names to lowercase format used by ObjectTypeget_models_from_content_types()in dashboard widgets to normalize model identifiersCUSTOM_VALIDATORSandPROTECTION_RULESlookups to check both real model names and lowercase namesBackward Compatibility
Both formats are supported:
dcim.Site,ipam.IPAddressdcim.site,ipam.ipaddress(existing behavior preserved)Fixes #21209