{{{
urlpatterns = ['', # leading string might be left by users converting from
patterns() in earlier Django versions
(r'^$', my_view),
url(r'^admin/', admin.site.urls),
]
}}}
{{{
File "site-packages/django/core/checks/urls.py", line 67, in
check_pattern_startswith_slash
regex_pattern = pattern.regex.pattern
AttributeError: 'tuple' object has no attribute 'regex'
}}}
I suggest that we should create a new warning if the pattern is not a
`url()` instance.
--
Ticket URL: <https://code.djangoproject.com/ticket/26440>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
I thought this might be a good ticket if somebody's looking for a ticket
during the Djangocon EU sprints. If it's not picked up, then I'll take a
look at it next week.
--
Ticket URL: <https://code.djangoproject.com/ticket/26440#comment:1>
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/26440#comment:2>
* owner: nobody => burhan
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/26440#comment:3>
* needs_better_patch: 0 => 1
* has_patch: 0 => 1
Comment:
Left comments for improvement on the
[https://github.com/django/django/pull/6375 PR].
--
Ticket URL: <https://code.djangoproject.com/ticket/26440#comment:4>
Comment (by alasdairnicol):
I've created a new pr, which builds on burhan's work.
https://github.com/django/django/pull/6514
--
Ticket URL: <https://code.djangoproject.com/ticket/26440#comment:5>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/26440#comment:6>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/26440#comment:7>
* needs_better_patch: 0 => 1
Comment:
Sorry for changing the patch after it had been reviewed. I've added a
couple more patches to the pull request
* Added explicit test that URL checks are recursive, and simplified other
url configs
* Added hints when users have a string or tuple instead of a url()
instance
I think the text of the hints could be improved. I'm not 100% sure that
the tuple hint is necessary - maybe saying the main warning 'Ensure that
urlpatterns is a list' is enough.
--
Ticket URL: <https://code.djangoproject.com/ticket/26440#comment:8>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/26440#comment:9>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"eb5d7bc2f465b055f4eb54a3d238502bdddb6d7e" eb5d7bc2]:
{{{
#!CommitTicketReference repository=""
revision="eb5d7bc2f465b055f4eb54a3d238502bdddb6d7e"
Fixed #26440 -- Added a warning for non-url()s in urlpatterns.
Thanks Burhan Khalid for the initial patch and knbk/timgraham
for review.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26440#comment:10>