Render html pages in templates/html_pages
This commit is contained in:
parent
e533b3b82e
commit
3ec79710ca
6 changed files with 35 additions and 0 deletions
0
pages/__init__.py
Normal file
0
pages/__init__.py
Normal file
3
pages/models.py
Normal file
3
pages/models.py
Normal file
|
@ -0,0 +1,3 @@
|
|||
from django.db import models
|
||||
|
||||
# Create your models here.
|
5
pages/urls.py
Normal file
5
pages/urls.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
from django.conf.urls.defaults import *
|
||||
|
||||
urlpatterns = patterns('pages.views',
|
||||
(r'^(?P<page>.+)/$', 'index'),
|
||||
)
|
18
pages/views.py
Normal file
18
pages/views.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
import os.path
|
||||
|
||||
from django.http import Http404
|
||||
from django.views.generic.simple import direct_to_template
|
||||
|
||||
from settings import DEPLOY_PATH
|
||||
|
||||
def index(request, page):
|
||||
|
||||
template = 'html_pages/%s/index.html' % page
|
||||
if not os.path.exists('%s/templates/%s' % (DEPLOY_PATH, template):
|
||||
raise Http404
|
||||
|
||||
c = {
|
||||
"page": template,
|
||||
}
|
||||
|
||||
return direct_to_template(request, "pages/index.html", c)
|
5
templates/pages/index.html
Normal file
5
templates/pages/index.html
Normal file
|
@ -0,0 +1,5 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
{% include page %}
|
||||
{% endblock %}
|
4
urls.py
4
urls.py
|
@ -16,3 +16,7 @@ if DEBUG:
|
|||
urlpatterns += patterns('',
|
||||
(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': '%s/static' % DEPLOY_PATH})
|
||||
)
|
||||
|
||||
urlpatterns += patterns('',
|
||||
(r'^', include("pages.urls"))
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue