I am very new to Django. I just set it up and tried to create a simple Hello world! web application. I follow the tutorial step by step. I ran the python command django-admin.py startproject mysite, which created a mysite directory with another mysite directory in it by witbh manage.py. The mysite subdirectory has init .py init .pyc settings.py settings.pyc urls.py urls.pyc wsgi.py wsgi.pyc.
In the external mysite directory, I created views.py which has the following code: -
from django.http import HttpResponse
def hello(request):
return HttpResponse("Hello world!")
In the mysite internal directory, in urls.py, I have the following code: -
from django.conf.urls import patterns, include, url
from mysite.views import *
urlpatterns = patterns('',
url(r'^hello/$', 'mysite.views.hello'),
But I get this error: -
ImportError at /hello/
No module named views
Request Method: GET
Django Version: 1.6.2
Exception Type: ImportError
Exception Value:
No module named views
Exception Location: /data/aman/mysite/mysite/urls.py in <module>, line 2
Python Executable: /usr/bin/python
Python Version: 2.6.6
Python Path:
['/data/aman/mysite',
'/usr/lib64/python26.zip',
'/usr/lib64/python2.6',
'/usr/lib64/python2.6/plat-linux2',
'/usr/lib64/python2.6/lib-tk',
'/usr/lib64/python2.6/lib-old',
'/usr/lib64/python2.6/lib-dynload',
'/usr/lib64/python2.6/site-packages',
'/usr/lib/python2.6/site-packages']
Server time: Tue, 25 Feb 2014 10:27:38 +0000
source
share