Onboarding a Django app within a Two Scoops-style project

two-scoops-of-django-banner

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:

  1. add line to icratings/urls.py and icratings/settings/base.py
  2. disintegrate test.py into tests/[forms,models,views].py
  3. put templates in project root’s templates/
  4. 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:
[python startline=”14″]
url(r’^polls/’, include(‘polls.urls’)),
[/python]

Open icratings/settings/base.py and add a line in LOCAL_APPS (( If you’re following along from my previous work log, then be sure you also have the ‘popsicles’ line.)):
[python linestart=”192″]
# Apps specific for this project go here.
LOCAL_APPS = (
‘polls’,
‘popsicles’,
)
[/python]

Disintegrate test.py into tests/ folder

In polls/, delete test.py. Create folder tests/, containing new test files:
[bash gutter=”false”]
polls/
tests/
__init__.py
forms.py
models.py
views.py
[/bash]

Move views to templates

Move the polls’ views from wherever they are to $SITE_URL/icratings/templates.

Create db tables

In shell, run:
[bash gutter=”false”]
$ python manage.py syncdb
[/bash]

You’ll see mentions of creating tables for ‘polls’ (and maybe ‘popsicles’).

Start the server:
[bash gutter=”false”]
$ python manage.py runserver
[/bash]
Point browser to http://127.0.0.1:8000/polls/.


One Reply to “Onboarding a Django app within a Two Scoops-style project”

Comments are closed.