Django: Getting Started Transcripts
Chapter: Course conclusion
Lecture: New projects and their structure
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
Way back in the beginning, you took the first steps towards a new Django project.
0:04
You installed Django and then used the Django admin command line tool to start a new project.
0:09
A Django project is comprised of the somewhat confusingly named Django apps. So the next step after creating a project is to create an app.
0:20
Django is a web framework after all. So of course it comes with a web server. The run server management command runs a development server on port 8000,
0:28
which you can use to test your code. Once you've used the start project and start app commands,
0:34
you'll end up with a directory structure that looks something like this. The structure has a bit of a weird doubling in it.
0:41
Whatever you named, your project will show up as your project root and then there
0:45
will be a system configuration directory named the same thing underneath it. Here, you see the alexandria in yellow as the project route and the one in
0:54
light blue as the configuration directory. The configuration directory has files for configuring and managing your Django project.
1:02
The WSGI and a WSGI files are used to wire your Django code to a production web server.
1:09
The settings.py file contains a number of variable declarations that are used to configure
1:14
your Django project, including the all important installed apps that lists all the apps you wish to use.
1:22
The URLs.py file maps URLs to views, the code that generates a web page. This file can also reference and include other URL mapping files so you can
1:31
create a hierarchy of mapping is to keep your code nice and organized. By default, Django uses SQLite as its database engine.
1:40
So once you've started creating models, you're going to see the db.sqlite3 file. You can change what database engine to use in settings.py.
1:48
Django provides a number of command line management tools for configuring and managing your project. You run these through the manage.py script.
1:58
This is a wrapper to the same code you used to run the start project and start app commands.
2:03
You structure your code in a Django project with one or more apps which really should have been called modules.
2:10
When you use the start app command to create an app, Django creates a cookie cutter set of files for you.
2:17
Each app has an admin.py file that controls how the app interacts with the Django admin web tool.
2:24
An apps.py file that contains meta information about the app. Models.py file that specifies data based model objects.
2:32
The tests.py file for app unit tests. A views.py file that contains views for generating web pages and a migrations directory
2:43
that contains scripts that help Django manage changes you make to your object models.