Permalink
Browse files

Fixed and updated the example app.

  • Loading branch information...
1 parent 44de0dd commit 97546057adcde2a5ee733bf65594d7bb732d3619 @jacobian jacobian committed May 10, 2011
Showing with 86 additions and 117 deletions.
  1. +11 −66 example/settings.py
  2. +0 −25 example/templates/faq/home.html
  3. +66 −0 example/templates/home.html
  4. +9 −26 example/urls.py
View
77 example/settings.py
@@ -1,10 +1,16 @@
-# Django settings for [name] project.
-import os, os.path, sys
+#
+# A minimal settings file that ought to work out of the box for just about
+# anyone trying this project. It's deliberately missing most settings to keep
+# everything simple.
+#
+# A real app would have a lot more settings. The only important bit as far as
+# django-FAQ is concerned is to have `faq` in INSTALLED_APPS.
+#
+
+import os
-#set DEBUG = False and django will send exception emails
-DEBUG = True
-TEMPLATE_DEBUG = DEBUG
PROJECT_DIR = os.path.dirname(__file__)
+DEBUG = TEMPLATE_DEBUG = True
DATABASES = {
'default': {
@@ -13,73 +19,12 @@
}
}
-# Local time zone for this installation. Choices can be found here:
-# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
-# although not all choices may be avilable on all operating systems.
-# If running in a Windows environment this must be set to the same as your
-# system time zone.
-TIME_ZONE = 'America/New_York'
-
-# Language code for this installation. All choices can be found here:
-# http://www.i18nguy.com/unicode/language-identifiers.html
-LANGUAGE_CODE = 'en-us'
-
SITE_ID = 1
-
-# If you set this to False, Django will make some optimizations so as not
-# to load the internationalization machinery.
-USE_I18N = True
-
-# Absolute path to the directory that holds media.
-# Example: "/home/media/media.lawrence.com/"
-MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media')
-
-# URL that handles the media served from MEDIA_ROOT. Make sure to use a
-# trailing slash if there is a path component (optional in other cases).
-# Examples: "http://media.lawrence.com", "http://example.com/media/"
-#MEDIA_URL = 'http://127.0.0.1:8000/site_media/'
-MEDIA_URL = '/media/' #
-
-# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
-# trailing slash.
-# Examples: "http://foo.com/media/", "/media/".
-ADMIN_MEDIA_PREFIX = '/admin_media/'
-
-# Make this unique, and don't share it with anybody.
SECRET_KEY = 'c#zi(mv^n+4te_sy$hpb*zdo7#f7ccmp9ro84yz9bmmfqj9y*c'
-
-# List of callables that know how to import templates from various sources.
-TEMPLATE_LOADERS = (
- 'django.template.loaders.filesystem.load_template_source',
- 'django.template.loaders.app_directories.load_template_source',
-)
-
-TEMPLATE_CONTEXT_PROCESSORS = (
- 'django.core.context_processors.auth',
- 'django.core.context_processors.media',
-)
-
-MIDDLEWARE_CLASSES = (
- #'django.middleware.cache.CacheMiddleware',
- 'django.middleware.common.CommonMiddleware',
- 'django.contrib.sessions.middleware.SessionMiddleware',
- 'django.contrib.auth.middleware.AuthenticationMiddleware',
- 'django.middleware.doc.XViewMiddleware',
-)
-
ROOT_URLCONF = 'urls'
-
-INTERNAL_IPS = (
- '127.0.0.1',
-)
-
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.
[os.path.join(PROJECT_DIR, "templates")]
)
-
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
View
25 example/templates/faq/home.html
@@ -1,25 +0,0 @@
-{% extends "faq/base.html" %}
-
-{% block body %}
-<h2>Welcome to the django-faq Example Project</h2>
-<p>
-Here are some options to try:
-<dl>
- <dt>The <a href="/grouped_faq/">'Grouped' FAQ</a><dt>
- <dd>This page uses the faq_list_by_group view.</dd>
- <br/>
- <dt>The <a href="/faq/">'Ungrouped' FAQ</a><dt>
- <dd>This page uses the faq_list view.</dd>
- <br/>
- <dt>The <a href="/raw_faq/">'Raw' FAQ</a><dt>
- <dd>This page uses the question_list view. It is intended for site testers. (Note that answers for this view are not autoescaped.)</dd>
- <br/>
- <dt>The <a href="/submit_faq/">FAQ Submission Form</a><dt>
- <dd>This page is an example of a form that allows a site visitor to submit an FAQ for possible future inclusion in the FAQs.</dd>
- <br/>
- <dt>The <a href="/admin/">Django admin</a><dt>
- <dd>Remember that you have to clean up submitted questions in the admin before the will be visible in the FAQ.</dd>
-</dl>
-</p>
-{% endblock %}
-
View
66 example/templates/home.html
@@ -0,0 +1,66 @@
+{% extends "faq/base.html" %}
+
+{% block body %}
+{% load url from future %}
+<h2>Welcome to the django-faq example project</h2>
+<p>
+ If you aren't seeing any data below, or if you're getting random 404s, make
+ sure you've loaded the sample data by running <code>./manage.py loaddata
+ faq_test_data</code>.
+</p>
+<p>Here are some options to try:</p>
+<dl>
+ <dt>The <a href="{% url "faq_topic_list" %}">topic list</a>.</dt>
+ <dd>This view shows a list of all the FAQ topic areas.</dd>
+
+ <dt>
+ A <a href="{% url "faq_topic_detail" "silly-questions" %}">topic detail</a>
+ page.
+ </dt>
+ <dd>
+ This shows the list of all questions in a given topic.
+ </dd>
+
+ <dt>
+ A <a href="{% url "faq_question_detail" "silly-questions" "your-quest" %}">question
+ detail</a> page.
+ </dt>
+ <dd>
+ This shows an individual question. Again, it'll only work if you've loaded
+ the sample data.
+ </dd>
+
+ <dt>
+ The <a href="{% url "faq_submit" %}">question submission</a> page.
+ </dt>
+ <dd>
+ You can submit questions here. You'll notice that submitted questions
+ don't immediately appear: they're set to "inactive" and have to be
+ approved via the site admin.
+ </dd>
+
+ <dt>
+ Speaking of the admin, here's <a href="{% url "admin:app_list" "faq" %}">the FAQ admin</a>.
+ </dt>
+ <dd>
+ Remember that you can clean up submitted questions in the admin before the
+ will be visible in the FAQ.
+ </dd>
+
+ <dt>
+ Finally, below are some questions fetched into this template using a
+ template tag - <code>{% templatetag openblock %} faq_list 3 as faqs
+ {% templatetag closeblock %}</code>.
+ </dt>
+ <dd>
+ Some FAQ questions include:
+ {% load faqtags %}
+ {% faq_list 3 as faqs %}
+ {% for faq in faqs %}
+ {{ faq.text }} {% if not forloop.last %}/{% endif %}
+ {% endfor %}
+ </dd>
+
+</dl>
+{% endblock %}
+
View
35 example/urls.py
@@ -1,35 +1,18 @@
from django.conf.urls.defaults import patterns, url, include
-from django.contrib import admin
+from django.contrib import admin; admin.autodiscover()
from django.conf import settings
-from django.views.generic.simple import direct_to_template
+from django.views.generic import TemplateView
import faq.views
-admin.autodiscover()
-
urlpatterns = patterns('',
- url(regex = r'^faq/$',
- view = faq.views.faq_list,
- name = 'faq_list',
- ),
- url(regex = r'^grouped_faq/$',
- view = faq.views.faq_list_by_group,
- name = 'faq_list_by_group',
- ),
- url(regex = r'^submit_faq/$',
- view = faq.views.submit_faq,
- name = 'submit',
- ),
- url(regex = r'^raw_faq/$',
- view = faq.views.question_list,
- name = 'question_list',
- ),
- url(regex = r'^$',
- view = direct_to_template,
- kwargs = {'template': 'faq/home.html'},
- name = 'home',
- ),
+ # Just a simple example "home" page to show a bit of help/info.
+ url(r'^$', TemplateView.as_view(template_name="home.html")),
+
+ # This is the URLconf line you'd put in a real app to include the FAQ views.
+ url(r'^faq/', include('faq.urls')),
- url(r'^admin/(.*)', include(admin.site.urls)),
+ # Everybody wants an admin to wind a piece of string around.
+ url(r'^admin/', include(admin.site.urls)),
# Normally we'd do this if DEBUG only, but this is just an example app.
url(regex = r'^static/(?P<path>.*)$',

0 comments on commit 9754605

Please sign in to comment.