Django: Difference between revisions

From Wildsong
Jump to navigationJump to search
Brian Wilson (talk | contribs)
mNo edit summary
Brian Wilson (talk | contribs)
mNo edit summary
Line 28: Line 28:
=== Crib sheet ===
=== Crib sheet ===


Set up a django "project"
I am working my way through the "getting started" tutorial and making my own notes here.
 
==== Set up a django "project" ====
 
  cd ~/Projects
  cd ~/Projects
  mkdir Django
  mkdir Django
Line 47: Line 50:
which just has number of registered clients and a send button.
which just has number of registered clients and a send button.


Create a GCM app
==== Create a GCM app ====


  # For simplicity, same place as the project.
  # For simplicity, same place as the project.
  cd ~/Projects/gcm_test_site  
  cd ~/Projects/gcm_test_site  
  python manage startpp gcm_server
  python manage startapp gcm_server


The gcm_form will have a page with an area for client status and a button to send a dispatch message.
The gcm_form will have a page with an area for client status and a button to send a dispatch message.
gcm_server/models.py

Revision as of 19:04, 3 September 2013

Starting working from a Packt Publishing copy of the Django book, then realized the book itself is an open source project here: http://djangobook.com/ I installed django as described in chaper 2 from the github repo.

Initial tests

My initial testing will be with SQLite, then I will move on to postgresql to get PostGIS going. SQLite is built in to Python so it's a pretty obvious track to follow.

I am also interested to see how to work with Django and Komodo 8.

Installing

I had an old copy installed (1.3.1) and wanted 1.5.2 before pitching headlong into the tutorial.

% sudo pip install django --upgrade
.
.
.
Successfully installed django
% python -c "import django; print(django.get_version())"
1.5.2

Minimal tester

Just want a page to come up so that I can install the Google Cloud Messaging for django thing and try it out. Will set up Django then go look at that page.

Crib sheet

I am working my way through the "getting started" tutorial and making my own notes here.

Set up a django "project"

cd ~/Projects
mkdir Django
cd Django
django-admin.py startproject gcm_test_site

Run it; connect from browser

cd gcm_test_site
python manage.py runserver 0.0.0.0:8000

Connect to the server using its name and port 8000, for example http://wildsong.biz:8000 (example only, nothing there!) You should see:

"It worked!
Congratulations on your first Django-powered page."

Now I need to get it to do something useful. For starters how about emulating the ugly GCM server page, which just has number of registered clients and a send button.

Create a GCM app

# For simplicity, same place as the project.
cd ~/Projects/gcm_test_site 
python manage startapp gcm_server

The gcm_form will have a page with an area for client status and a button to send a dispatch message.

gcm_server/models.py