Skip to content

Commit

Permalink
Fixed and updated the example app.
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobian committed May 10, 2011
1 parent 44de0dd commit 9754605
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 117 deletions.
77 changes: 11 additions & 66 deletions 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': {
Expand All @@ -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',
Expand Down
25 changes: 0 additions & 25 deletions example/templates/faq/home.html

This file was deleted.

66 changes: 66 additions & 0 deletions 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 %}

35 changes: 9 additions & 26 deletions 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>.*)$',
Expand Down

0 comments on commit 9754605

Please sign in to comment.