Playing with the Demo Site on the ActivePython AMI

In previous articles about the ActivePython AMI we covered setting it up and changing which web server it uses, but we skipped over the basic step of how to actually change the content of the default Django demo application that shows up when you launch the ActivePython EC2 instance. Let’s cover that now.
Point your browser to the URL of your EC2 instance (shown as “Public DNS” in the AWS management console). You should see a site that is pretty much a clone of cloud.activestate.com. It has links to the first tutorial, and some other useful content and resources.
On the right side of the page header, next to the Search field, you’ll see an “Admin” link. Click that and enter the following credentials for the demosite application:

  • Username: admin
  • Password: tralfamadore541 (default)

Before you do anything else, click the “Change password” link in the header and set the default password to something unique.
Changing the Django Admin Password
Once that’s done you can click on the “Home” link in the header breadcrumbs to go to the main Django administration page for demosite and explore the interface.
Django Site Admin
It looks a bit like a CMS interface, and you can indeed use it add users, add pages and edit content. Let’s try that.

Flat pages

Click on the Flat pages link to start editing the static content of the site. You can, for example go click “/” link in the URL column and edit the content for the main page.
Editing the main page
Though this is all very interesting, you probably didn’t spend all this time and effort setting up your own EC2 instance so you could change content on ActiveState branded templates. You’ll probably want to create your very own application, but before you do, let’s look at how templates work.

Django Templates

In demosite, as in most Django applications, the static content we were editing above is pulled in to a special div content block. Everything outside of that block is controlled by templates. These can be edited in a couple of ways, depending on how you’ve deployed your instance.
If you followed along with the Script Driven Development section of the Building a Python-centric WebServer in the Cloud tutorial, edits are made on your local machine then deployed using fab. As with the previous tutorial, I’ll step through editing the files on the live instance via ssh. The paths will be similar using Fabric, but you can ignore the versioned directory paths because fab creates those for you.
If you launched your ActivePython AMI using the AWS interface, log in with ssh using something like:

ssh -i /path/to/your/aws/key ubuntu@ec2-your-instance-ip-addr.compute-1.amazonaws.com

Once you’re in:

cd /var/www/demosite/releases/current/templates

Use vim or nano to edit the base.html file. Try changing the title block to something more personal. Remove or change links in the as_sitenav div block. Play around with moving or restyling the content inserted by the “{% … %}” Django template variables.
When you’re done, jump into flatpages/default.html to see how that template extends base.html.
To see your changes, restart apache:

sudo service apache2 restart

… and memcached, to make sure the cache is cleared:

sudo service memcached restart

If you’re a Django developer, all of this will seem pretty trivial, but if you’re new to the framework and want to dig a little deeper you may want to go through the excellent Writing your first Django app tutorial.

Recent Posts

Scroll to Top