Django + Raspberry Pi Tutorial (PART II)

UPDATE (1/11/2017): The new tutorial can be found at: http://raspberrypituts.com/raspberry-pi-django-tutorial-2017/

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 settings.py

On line 35 change:

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

Step 2: Change urls.py

Django uses a mapping file called urls.py 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 urls.py file looks like this:

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

 

My DjangoProject/FirstApp/views.py file looks like this

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

Step 4: Start the server

Step 5: Test it out!

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

Raspberry Pi Django Complete Tutorial

 

You may also like...

10 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:

    Hi,

    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/autoreload.py”, line 226, in wrapper
    fn(*args, **kwargs)
    File “/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py”, line 113, in inner_run
    autoreload.raise_last_exception()
    File “/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py”, line 249, in raise_last_exception
    six.reraise(*_exception)
    File “/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py”, line 226, in wrapper
    fn(*args, **kwargs)
    File “/usr/local/lib/python2.7/dist-packages/django/__init__.py”, line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
    File “/usr/local/lib/python2.7/dist-packages/django/apps/registry.py”, line 85, in populate
    app_config = AppConfig.create(entry)
    File “/usr/local/lib/python2.7/dist-packages/django/apps/config.py”, line 90, in create
    module = import_module(entry)
    File “/usr/lib/python2.7/importlib/__init__.py”, line 37, in import_module
    __import__(name)
    ImportError: No module named FirstApp

  1. May 19, 2015

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

Leave a Reply

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