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 see our video player troubleshooting guide to resolve the issue.

Django Files

In this lesson, you’re going to take another look at your project to see a few of the important files that you’re going to work with a lot:

  • manage.py: You won’t go inside this file, but it’s kind of the command center of your project, so a lot of commands that you run are going to sit inside this file.

  • myproject: Inside of the management app, which is the one you start with when you first create your project, there are two files that you’re going to work with. urls.py is used to route forward to your other app. settings.py has project-wide settings.

Inside example_app, the projects app you’ll be creating, you’ll have a few files. The most important ones are urls.py, views.py, and models.py.

00:00 All right. Let’s take another look at our bare-bones project to discuss a few of the important files that we’re going to work with a lot. So over here, I mentioned already before, we have manage.py.

00:11 Now, we’ll never actually go inside of manage.py, but it is kind of the command center of your project. A lot of commands that we run are going to sit inside of manage.py.

00:23 Inside of our terminal, we’re often going to call this file and then a certain function when we want to perform a Django-wide action. Inside of the management app—so, this is the one that comes when we first create the project—

00:37 inside of here, there’s two files that we’re going to touch. urls.pywe’re going to use this mostly just to route forward to our other app, but we’re going to take a look inside of this one here. And settings.py has project-wide settings. So, we’ll took a look at what this file looks like.

00:56 There’s a lot of code in here already that comes with Django. We actually don’t have to change too much in here most of the time, but we will come back to this file once in a while and adapt some of the settings when it’s necessary.

01:09 Inside of the projects app that we will be creating,

01:14 we have a couple of files. This is where we will mostly work: inside of our app. The most important files in here will be the urls file. It will be directing here from myprojectI’ll talk about this more in the next video.

01:28 This is where we will define our paths and we’ll make sure that if the user types something in the browser bar, our Django app is going to know what to do with this request.

01:38 Then, we’re going to use the views file. This is where we write our code logic in Django. We’ll also use the models file. This is where we’ll define how our database table should look like. All right, so those are the most important files: models, urls, and views.

01:54 We’ll also create a new folder in here called templates that is going to hold our HTML files—the Django template files that we’ll be working with.

02:04 So, this was a quick overview of the most important files that we will be working with in our project. Let’s head to the next video where I’ll discuss how does a request flow through a Django app. See you there!

reblark on Oct. 24, 2019

Well, that’s interesting. It looks like you are adding video segments to this tutorial as we speak. I went through the table of contents and found 3 new files that I had never seen. For instance, the Django Apps video is really welcome. It’s one of those things that you have to figure out for yourself, but an explanation like you have presented is very useful and welcome. I am impressed.

Martin Breuss RP Team on Oct. 26, 2019

Those were the videos I mentioned earlier that got lost during the upload to our platform. They were always meant to be part of the course, they just temporarily and accidentally fell into a digital crevasse :) 🏔📼🏔

Should be all fixed now!

reblark on Oct. 29, 2019

When you create virtual environment, it looks like the manage.py app is moved into the virtual environment folder. Is that right?

Martin Breuss RP Team on Oct. 30, 2019

No, creating a virtual environment doesn’t move any of your files around. All it does is create a folder (e.g. named .env, like here).

Also, you’ll want to create the virtual environment before you create your Django app. Therefore, at the time that you are making the virtual environment, there shouldn’t yet be a manage.py file in your folder.

Does that answer your question?

reblark on Oct. 30, 2019

Mostly, but I am a bit uncertain. I am now on my third iteration. Your response to my question about multiple projects was exactly what I was looking for. I am not sure that I have asked you the right question here. If you do “deactivate,” that just turns off the virtual environment and then when you do “clear” that just clears all the lines in the cli history. Then to get back into the virtual environment you have to “activate” again? Yes? And what happens if you don’t activate again?

Martin Breuss RP Team on Oct. 30, 2019

Yes, exactly. If you deactivate you exit the virtual environment. If you want to get back in that safe and contained environment that it provides, as well as have access to Django and other libraries you installed there, you’ll have to activate it again with:

source your_env_name/bin/activate

clear in your terminal only gives you a blank screen for visual purposes. If you scroll up, everything you typed is actually still there.

Become a Member to join the conversation.