user3562812
user3562812

Reputation: 1829

Trouble with adding a new file as view in Django

I am trying to add index.py as a view in Django but I keep getting Views Don't Exist error. However, it works with views.py, which is in the same folder as index.py Do I need to generate index.pyc?

Here is my urls.py:

# urls.py handles the request from client. 
# This is the first file that controller looks at when client

from django.conf.urls import patterns, include, url

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'Work_manager.views.home', name='home'),
    # url(r'^blog/', include('blog.urls')),

    url(r'^admin/', include(admin.site.urls)),
    url (r'^$', 'TasksManager.views.index.page'),
    url (r'^index$', 'TasksManager.views.index.page'),
)

index.py

from django.shortcuts import render
from django.http import HttpResponse
# View for index page.
def page (request) :
    return HttpResponse ("Hello world!" )

Thank you

Upvotes: 0

Views: 125

Answers (1)

Tanveer Alam
Tanveer Alam

Reputation: 5275

url (r'^$', 'TasksManager.index.page'),
url (r'^index$', 'TasksManager.index.page'),

No need to add views module name in your url as your url will map directly it page function in index module.

Upvotes: 1

Related Questions