This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
DEBUG = True | |
TEMPLATE_DEBUG = DEBUG | |
ADMINS = ( | |
('Randall Degges', '[email protected]'), | |
) | |
MANAGERS = ADMINS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django_consultants.views import * | |
from django.conf.urls.defaults import * | |
urlpatterns = patterns('', | |
(r'^$', main_page), | |
# Login / logout. | |
(r'^login/$', 'django.contrib.auth.views.login'), | |
(r'^logout/$', logout_page), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib.auth import logout | |
from django.http import HttpResponseRedirect | |
from django.shortcuts import render_to_response | |
def main_page(request): | |
return render_to_response('index.html') | |
def logout_page(request): | |
""" | |
Log users out and re-direct them to the main page. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rdegges@cora:~/code/django_consultants$ django-admin.py startapp portal | |
rdegges@cora:~/code/django_consultants$ ls portal/ | |
__init__.py models.py tests.py views.py | |
rdegges@cora:~/code/django_consultants$ cd portal/ | |
rdegges@cora:~/code/django_consultants/portal$ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.conf.urls.defaults import * | |
from portal.views import * | |
urlpatterns = patterns('', | |
# Main web portal entrance. | |
(r'^$', portal_main_page), | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.shortcuts import render_to_response | |
from django.contrib.auth.decorators import login_required | |
@login_required | |
def portal_main_page(request): | |
""" | |
If users are authenticated, direct them to the main page. Otherwise, | |
take them to the login page. | |
""" | |
return render_to_response('portal/index.html') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rdegges@cora:~/code/django_consultants$ mkdir -p templates/{registration,portal} | |
rdegges@cora:~/code/django_consultants$ touch templates/base.html templates/index.html | |
rdegges@cora:~/code/django_consultants$ touch templates/portal/portal.html templates/portal/index.html templates/portal/menu.html templates/portal/footer.html templates/portal/header.html | |
rdegges@cora:~/code/django_consultants$ touch templates/registration/login.html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% comment %} | |
This template is a completely 100% generic HTML5 template. | |
{% endcomment %} | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends "base.html" %} | |
{% comment %} | |
Main page of django_consultant's website. | |
{% endcomment %} | |
{% block head %} | |
<title>Django Consultants</title> | |
{% endblock %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends "base.html" %} | |
{% comment %} | |
This is the main template for all portal pages. | |
{% endcomment %} | |
{% block head %} | |
<title>Django Consultants | {% block title %}{% endblock %}</title> | |
{% endblock %} |