Django displays a blank page

First of all, I would like to admit that I am completely new to Django. I am doing my best. I am making my way through a book called "Starting Django E-Commerce." Not wanting to violate the right to copy, perhaps you guys can determine where I made a mistake. I am using Django 1.4.3, the book I am using was probably written for Django 1, maybe 1.1, but here.

my base.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "XHTML1-s.dtd" >
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>{% block title %}{% if page_title %}{{ page_title }} - {% endif %}
            {{ site_name }}{% endblock %}</title>
    <meta name="keywords" content="{{ meta_keywords }}" />
    <meta name="description" content="{{ meta_description }}" />
</head>
<body>
    {% block site_wrapper %}{% endblock %}
</body>
</html>

my catalog.html:

{% extends "base.html" %}

{% block site_wrapper %}
<div id="main">
    <a href="#content" class="skip_link">Skip to main content</a>
    <div id="banner">
            <div class="bannerIEPadder">
                    <div class="cart_box">
                            [link to cart here]
                    </div>
                    Modern Musician
            </div>
    </div>
    <div id="navigation">
            <div class="navIEPadder">
                    [navigation here]
            </div>
    </div>
    <div id="middle">
            <div id="sidebar">
                    <div class="sidebarIEPadder">
                            [search box here]
                    <br />
                            [category listing here]
                    </div>
            </div>
            <div id="content">
                    <a name="content"></a>
                    <div class="contentIEPadder">
                            {% block content %}{% endblock %}
                    </div>
            </div>
    </div>
    <div id="footer">
            <div class="footerIEPadder">
                    [footer here]
            </div>
    </div>
</div>
{% endblock %}

My index.html:

{% extends "catalog.html" %}

{% block content %}
    <h2>Welcome!</h2>
{% endblock %}

All these files are stored in the templates directory. This book suggests the following command:

python manage.py startapp preview

and configure my urls.py:

urlpatterns = patterns ('', ... (r '^ catalog / $', 'preview.views.home'),)

edit view.py in the preview directory:

from django.shortcuts import render_to_response

def home(request):
  return render_to_response("index.html")

, :

 [ ]    [ ]  [ ]  [ ]   !  [ ]

, , - . - ? (, ) .

base.html. :

python manage.py runserver localhost:8000      (wd: ~/websites/ecomstore) 
Validating models... 0 errors found Django version 1.4.3, using settings 'ecomstore.settings' 
Development server is running at http://www.localhost.com:8000/ Quit the server with CONTROL-C. 
[01/Apr/2013 02:13:06] "GET /catalog/ HTTP/1.1" 200 352 
[01/Apr/2013 02:13:08] "GET /catalog/ HTTP/1.1" 200 352 
[01/Apr/2013 02:13:09] "GET /catalog/ HTTP/1.1" 200 352 
[01/Apr/2013 02:33:33] "GET /catalog/ HTTP/1.1" 200 352

, .

+5
3

{% block content%} catalog.html base.html, < base, .

0

- . , , ( , eclipse). , (, !). , -! !

0

django, , , . .py Installed_app :

 INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'preview.apps.PreviewConfig',
]

urls.py URL:

from django.conf.urls import url,include
from django.contrib import admin

urlpatterns = [
  url(r'^$', include ('preview.urls')),
  url(r'^admin/', admin.site.urls),
]

after that you can make a python file in the preview folder and call it urls.py.and there you should define your url patten for your preview application.

from django.conf.urls import url
from . import views


urlpatterns = [
url(r'^$', IndexView.as_view()),
]

The final step is to define the views. To do this, go to views.py in the preview folder and run view.py

from django.views.generic import TemplateView

class IndexView(TemplateView):
  template_name = "index.html"
0
source

All Articles