samedi 27 juin 2015

django listing files instead of showing home page

I'm not able to figure out what's going wrong. I'm using pycharm and bitnami django stack for developing my first web application.

Here is my directory structure:

project name: myapp

location: C:\Bitnami\djangostack-1.7.8-0\apache2\htdocs\myapp

Directory structure:

myapp
    manage.py
    app
          admin.py
          models.py
          settings.py
          tests.py
          urls.py
          views.py
          wsgi.py

          migrations
    templates
          home.html

my settings.py has following data:

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'app',
)

ROOT_URLCONF = 'app.urls'

TEMPLATE_DIRS = (
    os.path.join(BASE_DIR, 'templates'),
)

my urls.py has following data:

from django.conf.urls import url

from . import views

urlpatterns = [
    url(r'myapp/', views.homepage, name='home'),
]

my views.py has following data:

from django.http import HttpResponse


def homepage(request):
    return HttpResponse("Hello, world!")

Now when I try to run:

http://localhost/myapp

It simply displays the list of files in the myapp directory

I'm not able to find why it is not executing from urls.py

Aucun commentaire:

Enregistrer un commentaire