I think it would be grand if Django checked for the existence of the
`urlpatterns` attribute when passing a module to `include` and raised a
clearer Exception if it is absent.
--
Ticket URL: <https://code.djangoproject.com/ticket/34812>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by David Sanders):
Hello,
Django already does this with:
> django.core.exceptions.ImproperlyConfigured: The included URLconf
'<module 'foo.urls' from '/path/to/foo/urls.py'>' does not appear to have
any patterns in it. If you see the 'urlpatterns' variable with valid
patterns in the file then the issue is probably caused by a circular
import.
🤔
--
Ticket URL: <https://code.djangoproject.com/ticket/34812#comment:1>
Comment (by The Epic):
Replying to [comment:1 David Sanders]:
> Hello,
>
> Django already does this with:
>
> > django.core.exceptions.ImproperlyConfigured: The included URLconf
'<module 'foo.urls' from '/path/to/foo/urls.py'>' does not appear to have
any patterns in it. If you see the 'urlpatterns' variable with valid
patterns in the file then the issue is probably caused by a circular
import.
>
> 🤔
Oh, you're right. I guess the message should be clearer. I don't really
see how circular imports would affect it.
--
Ticket URL: <https://code.djangoproject.com/ticket/34812#comment:2>
* status: new => closed
* resolution: => worksforme
Comment:
Ok marking as worksforme… raise a discussion on the Django Forum if you'd
like to discuss changing the message 👍
--
Ticket URL: <https://code.djangoproject.com/ticket/34812#comment:3>