This work log follows on the tasks performed in the previous article, First Licks of Two Scoops of Django. Consider skimming it first to see from where we are picking up.
Lets bring into our ‘icratings’ project the ‘polls’ app created as part of the Django 4-part tutorial.
The onboarding procedure:
- add line to icratings/urls.py and icratings/settings/base.py
- disintegrate test.py into tests/[forms,models,views].py
- put templates in project root’s templates/
- create database fields for model
Add new route to urls.py
Copy paste polls/ app to icratings/.
Add a line above the admin url section in icratings/urls.py:
url(r'^polls/', include('polls.urls')),
Open icratings/settings/base.py and add a line in LOCAL_APPS1:
# Apps specific for this project go here. LOCAL_APPS = ( 'polls', 'popsicles', )
Disintegrate test.py into tests/ folder
In polls/, delete test.py. Create folder tests/, containing new test files:
polls/ tests/ __init__.py forms.py models.py views.py
Move views to templates
Move the polls’ views from wherever they are to $SITE_URL/icratings/templates.
Create db tables
In shell, run:
$ python manage.py syncdb
You’ll see mentions of creating tables for ‘polls’ (and maybe ‘popsicles’).
Start the server:
$ python manage.py runserver
Point browser to http://127.0.0.1:8000/polls/.
- If you’re following along from my previous work log, then be sure you also have the ‘popsicles’ line. [↩]