-
-
Notifications
You must be signed in to change notification settings - Fork 31.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
Fixed #26440 -- Added system checks to verify urlpatterns contains valid objects. #6375
Conversation
errors = [] | ||
|
||
if not hasattr(pattern, 'regex'): | ||
errors.append(Warning("url objects should have a property regex", |
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.
This message should include some helpful information to debug the error. Currently it gives no information as to where the problem is. This is the idea behind the existing describe_pattern()
function.
"Remove this slash as it is unnecessary.".format(describe_pattern(pattern)), | ||
id="urls.W002", | ||
"Your URL pattern {} is not an object returned from the 'url()'" | ||
"method. If you are using a custom object, it should provide a `pattern`" |
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 a bit hesitant about exposing the private details of url resolving in user-facing messages, so I would remove the comment about a custom object. Custom url objects are an advanced and unsupported use-case (for now), and I think this warning should target the mistakes made when upgrading/using the new structure, not the ones made when replacing the internal and private details of url resolving.
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.
+1
Also, the tests aren't passing, e.g.:
|
This can be closed now that #6514 is merged. |
https://code.djangoproject.com/ticket/26440
url
, and ends up with a tuple(r'', foo, name=df)