CMS-like website

Provides a great starting point for using Django with Django-registration, Captcha, Bootstrap, and jQueryUI. Default base template provides a simple starting interface which you can expand on easily.

Provides a good base for a social community of some sort, where registration is available with Captcha along with a theme which most community sites use, a block-based theme.

Requirements:

import os.path
PROJECT_ROOT = os.path.normpath(os.path.dirname(__file__)+'/..')

DEBUG = True
TEMPLATE_DEBUG = DEBUG
INTERNAL_IPS = ('127.0.0.1',)

ADMINS = (
    # ('Your Name', 'your_email@example.com'),
)

MANAGERS = ADMINS

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': '',                      # Or path to database file if using sqlite3.
        'USER': '',                      # Not used with sqlite3.
        'PASSWORD': '',                  # Not used with sqlite3.
        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
    }
}

# 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 available on all operating systems.
# In a Windows environment this must be set to your system time zone.
TIME_ZONE = 'America/Winnipeg'

# 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

# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale.
USE_L10N = True

# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = True

# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media')

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = '/m/'

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static')

# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/s/'

# Additional locations of static files
STATICFILES_DIRS = (
    os.path.join(PROJECT_ROOT, 'bootstrap'),
    os.path.join(PROJECT_ROOT, 'jquery'),
    os.path.join(PROJECT_ROOT, 'tinymce'),
    os.path.join(PROJECT_ROOT, 'assets'),
)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#    'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

# Make this unique, and don't share it with anybody.
SECRET_KEY = ''

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
#     'django.template.loaders.eggs.Loader',
)

TEMPLATE_CONTEXT_PROCESSORS = (
    'django.contrib.auth.context_processors.auth',
    'django.core.context_processors.debug',
    'django.core.context_processors.i18n',
    'django.core.context_processors.media',
    'django.core.context_processors.static',
    'django.core.context_processors.tz',
    'django.contrib.messages.context_processors.messages',
    'django.core.context_processors.request',
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'debug_toolbar.middleware.DebugToolbarMiddleware',
    # Uncomment the next line for simple clickjacking protection:
    # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)

ROOT_URLCONF = 'project.urls'

# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'project.wsgi.application'

TEMPLATE_DIRS = (
    os.path.join(PROJECT_ROOT, 'templates'),
)

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'fluent_dashboard',
    'admin_tools',
    'admin_tools.theming',
    'admin_tools.menu',
    'admin_tools.dashboard',
    'django.contrib.admin',
    'registration',
    'captcha',
    'south',
    'debug_toolbar',
)

ACCOUNT_ACTIVATION_DAYS = 7

RECAPTCHA_PUBLIC_KEY = ''
RECAPTCHA_PRIVATE_KEY = ''

ADMIN_TOOLS_INDEX_DASHBOARD = 'fluent_dashboard.dashboard.FluentIndexDashboard'
ADMIN_TOOLS_APP_INDEX_DASHBOARD = 'fluent_dashboard.dashboard.FluentAppIndexDashboard'
ADMIN_TOOLS_MENU = 'fluent_dashboard.menu.FluentMenu'
ADMIN_MEDIA_PREFIX = STATIC_URL+'admin/'


# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'filters': {
        'require_debug_false': {
            '()': 'django.utils.log.RequireDebugFalse'
        }
    },
    'handlers': {
        'mail_admins': {
            'level': 'ERROR',
            'filters': ['require_debug_false'],
            'class': 'django.utils.log.AdminEmailHandler'
        }
    },
    'loggers': {
        'django.request': {
            'handlers': ['mail_admins'],
            'level': 'ERROR',
            'propagate': True,
        },
    }
}
from django.conf.urls import patterns, include, url
from registration.views import activate, register
from django.contrib import admin
from django.views.generic.base import TemplateView
from captcha.forms import RegistrationFormCaptcha
admin.autodiscover()

account_urls = patterns('',
    url(r'^activate/complete/$', TemplateView.as_view(template_name='registration/activation_complete.html'), name='registration_activation_complete'),
    url(r'^activate/(?P<activation_key>\w+)/$', activate, {'backend': 'registration.backends.default.DefaultBackend'}, name='registration_activate'),
    url(r'^register/$', register, {'backend': 'registration.backends.default.DefaultBackend', 'form_class':RegistrationFormCaptcha}, name='registration_register'),
    url(r'^register/complete/$', TemplateView.as_view(template_name='registration/registration_complete.html'), name='registration_complete'),
    url(r'^register/closed/$', TemplateView.as_view(template_name='registration/registration_closed.html'), name='registration_disallowed'),
    (r'', include('registration.auth_urls')),
)

urlpatterns = patterns('',
    url(r'^$', TemplateView.as_view(template_name='base.html')),
    url(r'^accounts/', include(account_urls)),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^admin_tools/', include('admin_tools.urls')),
)
{% load url from future %}
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Your Site | {% block title %}Home{% endblock %}</title>
    <script src="{{STATIC_URL}}js/jquery-1.8.2.js"></script>
    <script src="{{STATIC_URL}}js/jquery-ui-1.9.1.custom.min.js"></script>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <!-- Le styles -->
    <link href="{{STATIC_URL}}css/bootstrap.min.css" rel="stylesheet">
    <link href="{{STATIC_URL}}css/cupertino/jquery-ui-1.9.1.custom.min.css" rel="stylesheet">
    <link href="{{STATIC_URL}}css/bootstrap-responsive.min.css" rel="stylesheet">
    <style>
    body { background-color: #eeeeee; font-size: 10pt; }
    #brand { font-size: 18pt; font-family: courier; }
   .copyright { color: #888888; display: block; text-align: center; }
   .copyright a { color: #555555; }
   {% block css %}{% endblock %}
    </style>

    <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <script type="text/javascript">
    {% block javascript %}
    $(function(){
      $(".jqbutton").button();
      {% block jquery %}{% endblock %}
    });
   {% endblock %}
    </script>
    {% if not debug %}{% include "analytics.html" %}{% endif %}
  </head>

  <body>

    <div class="container">
      <div class="row">
        <div class="span3" id="brand">Your Site</div>
      </div>
      <div class="row">
        <div class="span3">
          <div class="ui-widget">
            <div class="ui-widget-header ui-corner-top"><span class="ui-icon ui-icon-grip-dotted-vertical" style="float:left;"></span>Navigation</div>
            <div class="ui-widget-content ui-corner-bottom"><ul>
            <li><a href="/">Home</a></li>
            </ul></div>
          </div>
          {% if not user.is_authenticated %}
          <div class="ui-widget">
            <div class="ui-widget-header ui-corner-top"><span class="ui-icon ui-icon-grip-dotted-vertical" style="float:left;"></span>Login</div>
            <div class="ui-widget-content ui-corner-bottom"><form action="{% url 'auth_login' %}" method="post">{% csrf_token %}
            <b>Username:</b> <input type="text" name="username" id="id_username" /><br/>
            <b>Password:</b> <input type="password" name="password" id="id_password" /><br/>
            <span class="pull-right"><a href="{% url 'registration_register' %}" class="jqbutton">Register</a></span>
            <input type="submit" value="Login" class="jqbutton" /></form></div>
          </div>
          {% else %}
          <div class="ui-widget">
            <div class="ui-widget-header ui-corner-top"><span class="ui-icon ui-icon-grip-dotted-vertical" style="float:left;"></span>User Panel</div>
            <div class="ui-widget-content ui-corner-bottom">Logged in as <b>{{user.username}}</b><br/><ul>
            <li><a href="{% url 'auth_logout' %}">Sign out</a></li>
            </ul></div>
          </div>
          {% if user.is_staff %}
          <div class="ui-widget">
            <div class="ui-widget-header ui-corner-top"><span class="ui-icon ui-icon-grip-dotted-vertical" style="float:left;"></span>Site Administration</div>
            <div class="ui-widget-content ui-corner-bottom"><a href="{% url 'admin:index' %}">Admin Interface</a></div>
          </div>
          {% endif %}
          {% endif %}
        </div>
        <div class="span9">
          <div class="ui-widget">
            <div class="ui-widget-header ui-corner-top"><span class="ui-icon ui-icon-grip-dotted-vertical" style="float:left;"></span>{% block heading %}Content{% endblock %}</div>
            <div class="ui-widget-content ui-corner-bottom">{% block content %}Content Block{% endblock %}</div>
          </div>
        </div>
      </div>
    </div> <!-- /container -->
    <div class="copyright">Python Powered | &copy; 2012 Your Site | <a href="http://www.pythondiary.com/">Blog</a> | <a href="#">Contact us</a></div>
  </body>
</html>
Download as ZIP

* ZIP file is automatically generated and some elements such as the SECRET_KEY are regenerated as well.

About Me

My Photo
Names Kevin, hugely into UNIX technologies, not just Linux. I've dabbled with the demons, played with the Sun, and now with the Penguins.




Kevin Veroneau Consulting Services
Do you require the services of a Django contractor? Do you need both a website and hosting services? Perhaps I can help.

If you like what you read, please consider donating to help with hosting costs, and to fund future books to review.

Python Powered | © 2012-2014 Kevin Veroneau