Locked learning resources

Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Locked learning resources

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Django by Error Messages

In this lesson, you’re going to learn about developing by error messages. It’s a great way to approach programming in general.

Error messages are your friends! They’re there to help you. Essentially, the computer is telling you, “Something’s not right. Here’s a helpful tip to help you solve your problem.”

00:00 Hey, and welcome to this section about developing a Django app following the error messages. So, I’ve mentioned this already before, and now we’re going to talk about developing by error messages. You might be feeling like, “Oh my god,” or, “No, please not!” Or even, “Ahhh!”

00:18 But developing by error messages is actually a great way to approach programming, in general. That’s something that I want to emphasize a lot here, really, because people starting off with programming, they seem to think of error messages as, like, they did something wrong and things are going wrong and, I don’t know, they don’t know what they’re doing at all, and maybe have no way of continuing as a programmer.

00:40 But that’s not true at all. Error messages are your friends. They’re there to help you. Essentially, the computer is telling you, “Wait, um, something’s not quite right, and here’s a helpful tip of how you could solve it.” Okay?

00:53 So, just think of error messages like that. Think of it as a tip from your computer friend, and then you’re going to be looking forward to finding error messages.

01:00 We’re going to train that by developing so that at the end of this course, if you find an error message, you’re going to be like, “All right, sweet! Welcome, new friend. Let’s figure out together what’s going on.” And maybe you’re even going to end up really liking seeing those error messages around. Okay, great.

01:16 So, Django has an actually very, very nicely built-out way of showing you error messages. Okay! So, let’s take a look at a Django error message. I headed over to my PyCharm, and here I’m going to start again our development server.

01:29 We will do that using python manage.py runserver as the command.

01:35 This starts up our development server at localhost port 8000, and now I can head over to this URL and we can see this install message.

01:47 This is similar to an error message, actually, just in this case, it’s a success message. So here, Django is telling you what you did worked out, so that’s great.

01:55 Now, we’re going to head over to look at how an error message would look like. For this, I’m going to navigate to a URL called /portfolio. We’re gonna build that one out later, but currently, if I go there, Django’s telling me, “Well, there’s nothing there,” or, “I can’t find what you’re telling me to find,” because we didn’t create this yet. We didn’t make a /portfolio or /projects.

02:18 These URLs don’t exist yet. So, what Django is telling me is, “I can’t find this page, sorry.” And the HTTP error associated that you’ve seen up on the web a couple of times is 404, which is essentially just, “I can’t find this resource.” You’re going to see this structure of error message often with Django.

02:36 So, we have this yellow bit at the top that tells us the name of the error message, and some helpful information. It’s telling us, “This is where I tried to find it. With this method, I tried to get something from there and I got a 404 error.

02:50 I couldn’t find it.” What Django also does—and we will see more of that in other error messages—is it gives you helpful tips down here. This can go, sometimes, really long.

03:01 It gives you tips on where to look. For example, here it’s telling us, “Take a look in .urls, because this is maybe where something got messed up,” right?

03:09 “Because this is where I’m routing you between the URLs that someone types here to the places in the app, where you are going to find the right resources.

03:17 And this is currently not working, so check that out,” et cetera, et cetera. So there’s helpful tips in here, in these gray parts. We’re going to take a look at those more once we encounter more and more error messages while developing our app.

03:31 Okay. So, but just so you know, you’ve seen that it’s yellow and gray, and these are the Django error messages, and these error messages are your friends. Okay.

03:41 So, let’s move on to actually building our app.

Avatar image for reblark

reblark on Feb. 18, 2020

By the way, this little discussion about error messages and your emphasis on reading them has been very helpful to me in every piece of development work that I have tackled. It’s great.

Avatar image for tomislavm021

tomislavm021 on July 19, 2020

I have created a project with django-admin startproject . So i added a “.” and now i dont have manage.py inside that project folder.

So i went back into cmd and creted a new project but this time without a dot on the end, and i got manage.py inside that project folder…

Any tips please? Thanks

Avatar image for Ricky White

Ricky White RP Team on July 20, 2020

Hi Tom,

The . tells Django to put the app files in the current working directory. If you provide it with a name instead of a dot, it will create a folder inside your current working directory that will contain the Django files. Be sure when you run startproject that your current working directory is where you want your Django files to live. This will be known as your root directory. The manage.py lives in your root directory along side your Django app. That is the intended behavior.

Avatar image for gregorysaison

gregorysaison on Jan. 21, 2021

What an excellent way to create a project from A to Z. I don’t know if it is a good way to make any project but for my first projects alone I think I’m gonna use this step by step error messages way. It will be a good method to have a good understanding of Django.

Thanks Martin!

Avatar image for Vasanth Baskaran

Vasanth Baskaran on Aug. 20, 2021

Nice usage of emoticons. Made me smile while watching the course video.

Avatar image for alphafox28js

alphafox28js on Sept. 5, 2024

After using vs-code, I cant handle anymore errors! :’(

Just kidding, just kidding ahahaha PyCharm here we come! :)

Felt the need to crack a joke at my own expense haha!

Avatar image for Martin Breuss

Martin Breuss RP Team on Sept. 5, 2024

@alphafox28js you should stick with VS Code, there’s no need to swich to PyCharm. The error messages that you’ll befriend in this course are all Django-specific error messages 🤗

Become a Member to join the conversation.