Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set your subtitle preferences in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please refer to our video player troubleshooting guide for assistance.

Making a GeoDjango App: Introduction & Overview

Thank you for joining me for this Real Python video series where you’ll be making a location-based web application with Django and GeoDjango. The app you’ll build will be a very simple one. You’ll have a data collection of shops in the city of Baltimore. This data will be queried to provide a subset of shops closest to a user’s location.

Let’s go over the list of tools you’ll be using in this tutorial:

  • Python version 3 will be the programming language you’ll use to create the application. You’ll code in a Python virtual environment and use pip to install required packages.

  • You need to store data for this project. This tutorial will walk you through installing PostGreSQL for that purpose. PostGreSQL is a relational database, and you’ll add the PostGIS extension to incorporate spatial data features.

  • For your backend web server, you will install the Django web framework and enable GeoDjango for spatial data support. GeoDjango is included with the Django installation.

GeoDjango will require some drivers for spatially modeling the data. These drivers can be tricky to install individually, so in the interest of time, this tutorial includes an installation of QGIS which is a great open source GIS application that as an added benefit, installs these drivers gracefully.

As an bonus, you’ll use Leaflet to produce a map with markers showing your user in a graphical way the shops that are nearby.

00:00 Hi everybody! Thank you for joining me for this Real Python video series, where you’ll be making a location-based web application with Django and GeoDjango. The app you’ll build will be very simple.

00:14 You’ll have a data collection of shops in the city of Baltimore. This data will be queried to provide a subset of shops closest to a user’s location. Let’s go over the list of tools you’ll be using in this tutorial.

00:28 Python version 3 will be the programming language you’ll use to create the application. You’ll code in a Python virtual environment and use pip to install required packages. You’ll need to store data for this project.

00:43 This tutorial will show you how to install PostgreSQL for that purpose.

00:48 Postgres is a relational database and you’ll add the PostGIS extension to incorporate spatial data features.

00:56 For your backend web server, you will install the Django web framework and enable GeoDjango for spatial data support. GeoDjango is included with the Django installation.

01:09 GeoDjango will require some drivers for spatially modeling our data. These drivers can be tricky to install individually, so in the interest of time and simplicity, this tutorial includes an installation of QGIS, which is a great open-source GIS application that as an added benefit installs these drivers gracefully. Finally, as a bonus, you’ll use Leaflet to produce a map with markers to show your user in a graphical way the shops that are nearby.

01:40 So, why this stack? For standard web applications, Django and PostgreSQL are great options. Django is one of the two most popular web frameworks for Python at the moment, and PostgreSQL is an established leader in open-source relational database systems.

01:57 The remaining components in this stack provide us with ways to represent and query spatial data, so let’s talk about spatial data for a moment. You’re building an app that lists shops near a user’s location, sorted by distance. You’ve probably seen similar applications.

02:13 It seems simple enough, right? Access the data, query it, and provide the user’s results. After all, if you wanted to see all shops in a city or in a zip code, that’s a fairly straightforward query. The nuance here, however, is that this app sorts by distance and that’s not something easily done with a regular query on a regular database.

02:33 When we try to query based on location, especially relative locations such as “Places within three miles of me,” or inside a boundary, we introduce some complexity. Is that distance a radius?

02:46 Does it take roads, access, and elevation into account? Sure, we could figure out some math related to latitude and longitude coordinates, but in general, if your app depends on geographic location, it’s better to have GIS capabilities in your database.

03:04 GIS stands for Geographic Information System. A GIS integrates data formats and functions for the purpose of collecting, managing, and analyzing spatial data.

03:16 Please join me in the next video, where we’ll set up the necessary components to make our location-based web application. See you there.

Peter T on May 4, 2019

This is an exceptional course and a extremely professional approach to teaching. It’s obvious to me that Jackie has finely honed her college teaching experience and it shows throughout these videos. Her thought process is completely easy to follow and she doesn’t leave any gaps for the readers to Google the answers for themselves. She has also transposed many of her video words into written words for the readers to peruse. Maybe these will turn into a fully complete written tutorial. (hint) Excellent course!

Jackie Wilson RP Team on May 5, 2019

Thank you so much for your feedback, Peter. Teaching is one of those professions where you’re always questioning and tweaking your approach/accuracy in a constantly changing field. It’s so nice to receive positive reinforcement, and I’m so grateful you took the time to submit your comments. I’m glad you found value in the videos, and to be fair, the course was loosely adapted from the article by the same name, written by Ahmed Bouchefra in December 2018: realpython.com/location-based-app-with-geodjango-tutorial/ While I did make quite a few changes, his article was the original inspiration. It’s so heartening to know my videos have been helpful. Your comment made my day/week/month…

louisdupre on Sept. 8, 2020

Hi,

Question. I’m using Django for my online website (MySql) with Cpanel. So I don’t use Django on my personnal computer. I got different apps. I’d like to use it for userprofile model. How I can install GEOS GDAL and PROJ.4? Directly by the pip?

I’ve tried with GDAL and I got an error (pip install GDAL).

Traceback (most recent call last):
  File "/tmp/pip-build-hw2ao46r/GDAL/setup.py", line 257, in get_gdal_config
    return fetch_config(option)
  File "/tmp/pip-build-hw2ao46r/GDAL/setup.py", line 154, in fetch_config
    raise gdal_config_error(e)
gdal_config_error: [Errno 13] Permission denied: 'gdal-config'

Could not find gdal-config. Make sure you have installed the GDAL native library and development headers. 

louisdupre on Sept. 8, 2020

Sorry for posting here button your buttons do not work on others chapters…

Become a Member to join the conversation.