The new Django site code creates two types of site administrators where before there was only one:
2. People adding new features to the site
The former group can now do everything they need to do through the admin interface built in to the site at: http://oclug.on.ca/admin/
The latter group needs a way to work on the code collaboratively, test changes and update the database schema when the changes are deployed.
Django has very good online documentation. The tutorial is a good place to start. Some other useful references:
Shortcuts to some of the files available from the “browse source” button above.
file | description |
__init__.py | allows directory to be imported as a module (python idiom) |
local_settings.py | database and secret key settings NOT IN SUBVERSION |
settings.py | global settings for the project |
urls.py | static mappings for URLs to views and templates |
sandbox_settings.py | overrides for sandbox site |
staging_settings.py | overrides for staging site |
manage.py | django utility script for managing the project |
dump.sh | script to dump all the non-sensitive data from the db as xml |
docroot | apache document root |
docroot:favicon.ico | special case fall-through for “favorites icon” |
docroot:media: | all requests to oclug.on.ca/media/ are served from this directory (apache config) |
docroot:media:admin | symlink to django's admin site media directory (for icons, etc.) |
docroot:media:uploaded | symlink to site_data/uploaded directory (for files and images uploaded to admin site) |
docroot:media:oclug.css | CSS for site |
docroot:media:oclug.png | site logo |
meetings | custom OCLUG meetings application |
meetings:models.py | meetings models, database field types and admin site customization |
meetings:views.py | custom view functions for meetings application |
meetings:feeds.py | RSS feed classes for meetings |
meetings:templatetags | extension code for templates |
meetings:templatetags:meetings_image.py | templatetag for uploaded images (to include size, title, alt, etc.) |
templates | templates that generate site HTML |
templates:base_generic.html | common site look, with logo, navigation bar and boxes |
templates:404.html | 404 (not found) page |
templates:500.html | 500 (server error) page |
templates:meetings | templates for meetings application |
templates:meetings:upcoming.html | page for upcoming meetings and announcements |
templates:meetings:past.html | page past meetings |
templates:meetings:meeting_detail.html | page for an individual meeting |
templates:meetings:location_detail.html | page for a meeting location |
templates:meetings:speaker_detail.html | page for a speaker |
templates:meetings:image_detail.html | page for single-image view |
templates:meetings:meeting_brief.html | a one-line view of a meeting (page fragment) |
templates:meetings:meeting_info.html | a detailed view of a meeting (page fragment) |
templates:admin | overrides for admin site templates |
templates:admin:base_site.html | modified version that includes a link to markdown reference |
templates:feeds | RSS feed templates |
templates:feeds:upcoming_description.html | meeting description (currently blank) |
templates:feeds:upcoming_title.html | meeting title |
templates:flatpages | flatpages application templates |
templates:flatpages:default.html | flatpage layout |
#!rst +-----------------------------+-----------------------------+------------------------------+ |"extends" |page template |"includes" | +=============================+=============================+==============================+ |base_generic.html |meetings/upcoming.html |meetings/meeting_info.html | + +-----------------------------+ + | |meetings/meeting_detail.html | | + +-----------------------------+------------------------------+ | |meetings/past.html |meetings/meeting_brief.html | + +-----------------------------+ + | |meetings/speaker_detail.html | | + +-----------------------------+ + | |meetings/location_detail.html| | + +-----------------------------+------------------------------+ | |meetings/image_detail.html | | + +-----------------------------+ + | |flatpages/default.html | | + +-----------------------------+ + | |400.html | | + +-----------------------------+ + | |500.html | | +-----------------------------+-----------------------------+------------------------------+
#!rst ============================= ================================================================= application description ----------------------------- ----------------------------------------------------------------- django.contrib.auth users, groups and permissions django.contrib.contenttypes django.contrib.sessions session tracking (required by auth) django.contrib.sites multiple site support (required by flatpages) django.contrib.admin administration interface http://oclug.on.ca/admin/ django.contrib.markup markup template tags, used for markdown formatted text django.contrib.flatpages database-backed pages, used for http://oclug.on.ca/about/, etc. django.contrib.redirects database-backed redirection, used to fix .php urls mostly meetings custom OCLUG meetings application ============================= =================================================================
Main OCLUG site
#!rst ==================== ================================== ============================================================= code location /home/webdude/oclug_django_site/ "push_staging_to_production" script used to copy from staging settings file settings.py data location /home/webdude/site_data/ checked in to SVN: /site_data/trunk/ upload location /var/local/main_site_uploaded/ owned by www-data, file and image uploads go here database Postgres: "oclug_django_site" serialized database /home/webdude/site_data/db.xml "serialize_db_and_checkin" script called nightly ==================== ================================== =============================================================
Site for testing new code and db columns/tables
#!rst ==================== ======================================== ============================================================= code location /home/webdude/staging/oclug_django_site/ "update_staging" script used to update from SVN settings file staging_settings.py data location /home/webdude/site_data/ shared with main site upload location /var/local/main_site_uploaded/ shared with main site database Postgres: "oclug_django_site" shared with main site serialized database none data not serialized ==================== ======================================== =============================================================
Site for testing changes made by admin interface
#!rst ==================== ======================================== ============================================================= code location /home/webdude/sandbox/oclug_django_site/ copied from main site by "reset_sandbox" script settings file sandbox_settings.py data location /home/webdude/sandbox/site_data/ copied from main site by "reset_sandbox" script upload location /var/local/sandbox_site_uploaded/ copied from main site by "reset_sandbox" script database Postgres: "oclug_django_sandbox_site" reloaded from main site by "reset_sandbox" script serialized database none data not serialized ==================== ======================================== =============================================================
main and staging sites share database and upload directory so that common changes (adding columns to a table and creating new models) can be tested with the live data. When there are new columns or tables the main site will ignore them.
This is a list of the maintenance script locations and what they do.
/home/webdude/bin/nightly (run from crontab daily at 4am)
2. call reset_sandbox
/home/webdude/bin/serialize_db_and_commit (called by nightly script)
2. rsync uploads into site data dir
3. check in everything in site data dir to SVN. This will cause changes to be emailed out like other SVN commits, and everyone on the oclug-www list will be able to see what has changed on the site.
/usr/local/bin/reset_sandbox → /home/webdude/bin/reset_sandbox (called by nightly script)
2. dump site database into sandbox database
3. restart apache
/usr/local/bin/update_staging → /home/webdude/bin/update_staging
2. “manage.py validate && manage.py syncdb” if any errors, stop and notify user
3. restart apache
/usr/local/bin/push_staging_to_production → /home/webdude/bin/push_staging_to_production
2. restart apache
How do we accommodate changes to the database layout (other than new tables that are handled by “manage.py syncdb”?