Skip to content

Commit

Permalink
Added routing and created a couple pages
Browse files Browse the repository at this point in the history
  • Loading branch information
jledbetter committed Aug 14, 2011
1 parent a72839a commit 31ee8dc
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 8 deletions.
6 changes: 5 additions & 1 deletion recipes/views.py
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# Create your views here.
from django.views.generic.simple import direct_to_template

def homepage(request):
# Return an http response that serves the index.html template
return direct_to_template(request, 'homepage/index.html')
4 changes: 1 addition & 3 deletions settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@
ROOT_URLCONF = 'cookbook.urls'

TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
'templates/'
)

INSTALLED_APPS = (
Expand Down
15 changes: 15 additions & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!doctype html>
<!--[if lt IE 7]> <html lang="en-us" class="no-js ie6"> <![endif]-->
<!--[if IE 7]> <html lang="en-us" class="no-js ie7"> <![endif]-->
<!--[if IE 8]> <html lang="en-us" class="no-js ie8"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en-us" class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge;chrome=1" >
<title>{% block title %}{% endblock %} | Cookbook</title>
</head>

<body>
{% block body %}{% endblock %}
</body>
</html>
9 changes: 9 additions & 0 deletions templates/homepage/about-us.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% extends "base.html" %}

{% block title %}{{ _('About Us') }}{% endblock %}

{% block body %}

<h1>About Us</h1>

{% endblock %}
8 changes: 8 additions & 0 deletions templates/homepage/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% extends "base.html" %}

{% block title %}{{ _('Home') }}{% endblock %}

{% block body %}
Hello World

{% endblock %}
11 changes: 7 additions & 4 deletions urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
admin.autodiscover()

urlpatterns = patterns('',

# Uncomment the admin/doc line below to enable admin documentation:
url(r'^$', 'recipes.views.homepage', name='homepage'),
(r'^admin/doc/', include('django.contrib.admindocs.urls')),

# Uncomment the next line to enable the admin:
(r'^admin/', include(admin.site.urls)),
)

urlpatterns += patterns('django.views.generic.simple',
url(r'^about-us/$', 'direct_to_template', {
'template': 'homepage/about-us.html',
}, name='about_us'),
)

0 comments on commit 31ee8dc

Please sign in to comment.