Create the App
In this lesson, you’re going to create your first Django app. The command you need to use is
python manage.py startapp projects. You’re going to start by creating this app and will later flesh it out, as you saw in the first section of this course.
Head over to
projects and see your page running. You’ll get a message telling you that this site can’t be reached. You stopped the development server, so it’s not currently running. You can start solving this problem by opening up an extra terminal tab and starting your development server with
python manage.py runserver and just keeping it running.
When you reload the page, you still get an error message. It turns out that the URL isn’t pointing to anything. The error message points you toward
portfolio.urls. Take a look at
urls.py in the
In this video, we’re going to create the first self-standing Django app. For this, I’ll head over to PyCharm and the command to create an app in here is going to be
python manage.py—so, this is often the center where we do all our commands from—and then we’re going to say,
startapp and give it a name.
Okay, so, it looks like nothing happened, but if we refresh this up here, similar to before, when we created our management app, when we ran this
django-admin startproject, we got this management app and now with the command
manage.py startapp, and also giving it a name, we get a new app in here.
And this looks different than the management app, as you can see. So now, every app that you’re going to create is going to look like this. The management app is a bit different as in that it contains the
wsgi file, and the others—sorry,
__init__ all exist in these ones.
We already talked about the files a bit, but this is the basic structure of every Django app. So, can I now already head over to
/projects, what I tried before, and see our page running? Let’s give it a try.
The thing is that I stopped the development server before, so it’s currently not running. To solve this, and then still be able to interact with our terminal, I’m just going to open up an extra terminal. Tap here, and here I’m going to start our development server:
02:39 Lots of tips from Django and just so you know what’s happening here, PyCharm sometimes makes these things smaller so that you don’t see everything that’s going on. There’s still imports happening here.
So, it’s already pointing us towards where we are going to have to add something or change something in order to continue. And we’re going to do that in just a moment, in one video over this one, where we’re going to start talking about the routes. But before that, we’re going to take a little excursion and look at Django’s
Become a Member to join the conversation.