Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Django Basics Model Administration First App View

Shana HT
Shana HT
3,292 Points

ModuleNotFoundError: No module named 'courses.urls'

urlpatterns = [
    url(r'^courses/', include('courses.urls')),
    url(r'^admin/', admin.site.urls),
    url(r'^$', views.hello_world),
]

What would be triggering this error? I believe I used include correctly here.

urls.py in courses directory

from django.conf.urls import url

from .import views

urlpatterns = [

    url(r'^$', views.course_list),

]

2 Answers

I don't know what your imports look like in your project's urls.py file, since you didn't include them, but I'm guessing it's because you didn't import the include. If it doesn't look like this

from django.conf.urls import url, include

, then changing it should fix your issue. If that's not your problem, I'm not sure where it stems from, since your code looks like mine at that stage. If you followed all the steps leading up to this point, you should be good if you're importing include properly and didn't make a typo elsewhere.

Shana HT
Shana HT
3,292 Points

Thanks. I actually had a typo. It was really silly. But the only way to find it was to step away from the computer and take a break. I was totally blind to it at first.

I know how it goes, haha. That's usually the best thing you can do, especially if you've been reading and writing code for a while. Glad you got it sorted out.