Django + Raspberry Pi Tutorial (PART II)

UPDATE (1/11/2017): The new tutorial can be found at:

This tutorial will walk you through how to setup your first Django Web Application on your Raspberry Pi. The Django + Raspberry Pi Tutorial is is based off of the work done in the previous tutorial – Django + Raspberry Pi Tutorial (PART I).

Step1: Change

cd DjangoProject/DjangoProject/

On line 35 change:


Note: I added ‘FirstApp’ which is the name of the application we created in the last tutorial.

Step 2: Change

Django uses a mapping file called which maps html addresses to views, using regular expressions. Django maps a requested url to a view which is needed for a response via regular expressions. My file looks like this:

from django.conf.urls import include, url
from django.contrib import admin
from FirstApp.views import foo

urlpatterns = [
    # url(r'^admin/', include(,
    url(r'FirstApp/$', foo),

Step 3: Head over to our /DjangoProject/FirstApp/ for an edit

cd DjangoProject/FirstApp/


My DjangoProject/FirstApp/ file looks like this

from django.shortcuts import render
from django.http import HttpResponse

def foo(request):
 return HttpResponse("Hello World!")

The foo is the Python import string to get to a view.

Step 4: Start the server

cd FirstDjangoApp
python runserver

Step 5: Test it out!

Head over to and you should see “Hello World!” Comment if you have any issues or suggestions.

Raspberry Pi Django Complete Tutorial


You may also like...

12 Responses

  1. USMCguy says:

    You mentioned at the beggining of this tutorial, “Note: I added ‘FirstApp’ which is the name of the application we created in the last tutorial.”. However, I cannot find the reference anywhere. I even used google to search your entire site. The only mention of ‘FirstApp’ is in this tutorial. Did it get removed?

  2. Evgeny says:


    I followed all the instructions, but got the error.
    Whats my mistake?

    Unhandled exception in thread started by
    Traceback (most recent call last):
    File “/usr/local/lib/python2.7/dist-packages/django/utils/”, line 226, in wrapper
    fn(*args, **kwargs)
    File “/usr/local/lib/python2.7/dist-packages/django/core/management/commands/”, line 113, in inner_run
    File “/usr/local/lib/python2.7/dist-packages/django/utils/”, line 249, in raise_last_exception
    File “/usr/local/lib/python2.7/dist-packages/django/utils/”, line 226, in wrapper
    fn(*args, **kwargs)
    File “/usr/local/lib/python2.7/dist-packages/django/”, line 27, in setup
    File “/usr/local/lib/python2.7/dist-packages/django/apps/”, line 85, in populate
    app_config = AppConfig.create(entry)
    File “/usr/local/lib/python2.7/dist-packages/django/apps/”, line 90, in create
    module = import_module(entry)
    File “/usr/lib/python2.7/importlib/”, line 37, in import_module
    ImportError: No module named FirstApp

  3. John says:

    There are numerous within the projects/django directories. Which one are you referring to above?

  4. John says:

    Note: I added ‘FirstApp’ which is the name of the application we created in the last tutorial.
    where did you do this?

    I did not see a file named FirstApp in

  1. May 19, 2015

    […] Check out the next tutorial. […]

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.