Extensible Calendar
This page documents an example of using the Extensible Calendar Pro API with Django as the back end.
Contents
The Back End
First, we will set up the back end.
Creating the App with Source Control
Start by making a new Django project and app.
$ django-admin.py startproject cse330calendar
$ cd cse330calendar
$ python manage.py startapp cal
Right now would be a good time to set up your IDE and source control. Create a new Komodo project in the "cse330calendar" directory, and set up a repo on the "cse330calendar" in SourceTree. Make frequent commits after each step of the process.
Initial Configuration
Go into settings.py and configure your database.
Enable the admin panel, which requires editing both settings.py and urls.py. Add the cal application to the admin panel by creating cal/admin.py with the following content:
from django.contrib import admin
# We will create these models in the next step
from cal.models import Cal, Event
admin.site.register(Cal)
admin.site.register(Event)
Finally, add "cal" to the INSTALLED_APPS list in settings.py.
Creating the Models
Set up the models required for the Extensible Calendar. We have already done this work for you. Copy the following code into your cal/models.py file.
from django.db import models
# Extensible wants two models: a "calendar" model and an "event" model.
# The "calendar" model represents a collection of events. Note that the end
# application supports multiple calendars in the same view, with the events
# in each calendar having a different background color.
#
# First we will define our calendar model, `Cal`, and then we will define
# our event model, `Event`.
class Cal(models.Model):
# Title of the calendar
title = models.CharField(max_length=50)
# Text description of the calendar
description = models.CharField(max_length=200)
# Color ID (1-32)
color = models.IntegerField(default=1)
# Boolean for whether the calendar is hidden by default
hidden = models.BooleanField(default=False)
class Event(models.Model):
# Declare a one-to-many relationship with Cal
cal = models.ForeignKey(Cal)
# Title of the event
title = models.CharField(max_length=50)
# DateTime of event start
start = models.DateTimeField()
# DateTime of event end
end = models.DateTimeField()
# Additional information that can be associated with an event:
loc = models.CharField(max_length=50) # Location
notes = models.CharField(max_length=200) # Notes
url = models.CharField(max_length=100) # URL
ad = models.BooleanField(default=False) # Is this an all-day event
rem = models.CharField(max_length=200) # Reminder