Disclaimer: I just found the blog aspect of wikis.utexas.edu and it seems kinda duplicating of blogs.utexas.edu but I need to document some things and they kinda go here and they kinda don't so bare with me.


The purpose of this post is to detail the steps that a developer takes to start a brand new Project/Application within the PyPE environment.  I believe the assumption here is that the developer has already performed the following:

  1. Created a Project Group within the PyPE interface which also creates the repository in UTForge.
  2. Installed PyPE on their local machine.
  3. Using subversion checked out the project from UTForge Repository
  4. Created an application directory in the project directory

TEMPLATE_LOADERS should look like this:

# 'django.template.loaders.eggs.Loader',

Notice the first loader deals with caching and will speed up the loading of your pages. One draw back is that if you are developing locally and working on your templates you will have to force a complete reload of your template page which will be an extra step that you may get tired of or you will need to comment out the "django.template.loaders.cached.Loader" as shown in following code. With the cached loader present you are using a tuple denote which templates are being cached and when commented out below you are just listing template loaders.

# ('django.template.loaders.cached.Loader',(
'django.template.loaders.app_directories.Loader',# )),
# 'django.template.loaders.eggs.Loader',

INSTALLED_APPS should look like this:

    # Uncomment the next line to enable the admin:
    # 'django.contrib.admin',
    # Add your apps created with 'python manage.py my_app':*
urls.py at project level

At the project level you want to pass all http requests received by your application down to your application urls.py file so in line 4 all requests are captured and handled by the included application urls.py file

urlpatterns should look like this:

01 urlpatterns = patterns('',
03     # Example:
04     (r'^', include('projectgrp_name.project_name.app_name.urls')),   # Application url file
06     # Uncomment the admin/doc line below and add 'django.contrib.admindocs'
07     # to INSTALLED_APPS to enable admin documentation:
08     # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
10     # Uncomment the next line to enable the admin:
11     # (r'^admin/', include(admin.site.urls)),
12  )
urls.py at the application level

urlpatterns should look like this:

 urlpatterns = patterns('',

     # Example:
     (r'$'     , 'projectgrp_name.project_name.app_name.views.index'),
     (r'dapp/$', 'projectgrp_name.project_name.app_name.views.index'),
views.py at the application level

Within the views module you will import in some shortcuts to help you with return an http response in your view function and you will import in the UTDirectContext module as well. The index view function is very basic in that it just returns the test.html template page without adding any data to it.

# Create your views here.
from django.shortcuts import render_to_response, redirect
from utdirect.templates import UTDirectContext

defaults = {
    'window_title': 'University of Texas/Basic UT Direct Application',
#    'css_file': ['/apps/projectgrp_name/project_name/static/basic.css',],
#    'js_file': ['1.js', '2.js'],  # create and put js files here
    'api_key': '8B54A49X54',

def index(request):
    context = {}
    return render_to_response('test.html',UTDirectContext(request, context, defaults=defaults))
template directory

You will create a template directory within your application directory which will contain any templates you want to create.

test.html template

In the templates directory you just created you will create a template called test.html that will include variables for the UTDirect wraparound(header and footer) as well basic html so you can determine that your page is loading. 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <title>My Page</title>
  <meta name="robots" content="NONE,NOARCHIVE">
  Hello World!
{{ utd_footer}}