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 Test Time Template Tests

Sagar Thakkar
Sagar Thakkar
8,814 Points

django.core.urlresolvers.NoReverseMatch: 'courses' is not a registered name

it shows this error 3 times like below............

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Creating test database for alias 'default'...                                                                                                                                            
..EEE                                                                                                                                                                                    
======================================================================                                                                                                                   
ERROR: test_course_detail_view (courses.tests.CourseViewTest)                                                                                                                            
----------------------------------------------------------------------                                                                                                                   
Traceback (most recent call last):                                                                                                                                                       
  File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-packages/django/                                                                                                              
    extra, resolver = resolver.namespace_dict[ns]                                                                                                                                        
KeyError: 'courses'                                                                                                                                                                      

During handling of the above exception, another exception occurred:                                                                                                                      

Traceback (most recent call last):                                                                                                                                                       
  File "/home/treehouse/workspace/learning_site/courses/tests.py", line 59,                                                                                                              
    resp = self.client.get(reverse('courses:detail', kwargs={'pk':self.cour                                                                                                              
  File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-packages/django/                                                                                                              
    key)                                                                                                                                                                                 
django.core.urlresolvers.NoReverseMatch: 'courses' is not a registered name 

======================================================================                                                                                                                   
ERROR: test_course_list_view (courses.tests.CourseViewTest)                                                                                                                              
----------------------------------------------------------------------                                                                                                                   
Traceback (most recent call last):                                                                                                                                                       
  File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-packages/django/                                                                                                              
    extra, resolver = resolver.namespace_dict[ns]                                                                                                                                        
KeyError: 'courses'                                                                                                                                                                      

During handling of the above exception, another exception occurred:                                                                                                                      

Traceback (most recent call last):                                                                                                                                                       
  File "/home/treehouse/workspace/learning_site/courses/tests.py", line 50,                                                                                                              
    resp = self.client.get(reverse('courses:list'))                                                                                                                                      
  File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-packages/django/                                                                                                              
    key)                                                                                                                                                                                 
django.core.urlresolvers.NoReverseMatch: 'courses' is not a registered name  

======================================================================                                                                                                                   
ERROR: test_step_detail (courses.tests.CourseViewTest)                                                                                                                                   
----------------------------------------------------------------------                                                                                                                   
Traceback (most recent call last):                                                                                                                                                       
  File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-packages/django/                                                                                                              
    extra, resolver = resolver.namespace_dict[ns]                                                                                                                                        
KeyError: 'courses'                                                                                                                                                                      

During handling of the above exception, another exception occurred:                                                                                                                      

Traceback (most recent call last):                                                                                                                                                       
  File "/home/treehouse/workspace/learning_site/courses/tests.py", line 64,                                                                                                              
    resp = self.client.get(reverse('courses:step', kwargs={'course_pk':self                                                                                                              
  File "/usr/local/pyenv/versions/3.5.0/lib/python3.5/site-packages/django/                                                                                                              
    key)                                                                                                                                                                                 
django.core.urlresolvers.NoReverseMatch: 'courses' is not a registered name                                                                                                              

----------------------------------------------------------------------                                                                                                                   
Ran 5 tests in 0.081s                                          
FAILED (errors=3)                                                                                                                                                                        
Destroying test database for alias 'default'...                                                                               

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ please help...

[MOD: added ```python formatting -cf]

1 Answer

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,454 Points

The KeyError suggests the url name isn't "courses". Check the url.py or equivalent for a typo. Is it named "course" by mistake?