Reputation: 2109
I have created a Django project foo
.
├── manage.py
└── foo
├── __init__.py
├── settings.py
├── templates
│ ├── xyz.html
│ └── abc.html
├── tests.py
├── urls.py
├── views.py
└── wsgi.py
In views.py
, I have created two class based view HomePage
and ListPage
And routing configuration defined like this in urls.py
:
urlpatterns = patterns('',
url(r'^$', HomePage.as_view() , name='home'),
url(r'^list$', ListPage.as_view(), name='list'),
# url(r'^admin/', include(admin.site.urls)),
)
Throws Error:
(InteractiveConsole)
>>> import django
>>> django.setup()
>>> from django.core.urlresolvers import resolve
>>> resolve('/')
ResolverMatch(func=<function HomePage at 0x7f77769bb9d8>, args=(), kwargs={}, url_name='home', app_name='None', namespace='')
>>> resolve('list')
Traceback (most recent call last):
File "<console>", line 1, in <module>
...
raise Resolver404({'path': path})
django.core.urlresolvers.Resolver404: {'path': 'list'}
What's going wrong here? Default root url '/' is resolving but 'list' is not resolving
Upvotes: 2
Views: 929
Reputation: 2109
This was a silly mistake of mine :). Though It might be helpful to somebody.
try
>>resolve('/list')
Upvotes: 3