In Hour 1, "Understanding Django," you learned some of the basics about the Django framework. This hour guides you through the steps of creating a functional website called iFriends. Although this website will be basic, it will be the basis for future hours to build on as you are guided through the various aspects of the Django framework.
Let's begin the process of creating a working website by creating a Django project. A Django project is a collection of settings that define a specific instance of Django. These settings include things such as database configuration, URL configuration, and other options that you will learn about as the hours tick by.
Try It Yourself: Create Your First Django ProjectCreating a Django project is relatively simple to do from the command prompt. In this section, you create a project called iFriends.
Watch Out! Because the project will act as a Python package, avoid using a project name that conflicts with any existing built-in Python packages. The documentation for built-in Python packages can be found at http://www.python.org. There is no need to put your project code in a directory in the web server's document base. The Django framework will be responsible for executing the code. In fact, it is a much better idea to store the code somewhere outside the web server's root. That way your code will be protected from being accessed directly from a web browser. The startproject command first creates a directory called iFriends, and then it stores the basic set of Python files that are needed to begin the project in the iFriends directory. The startproject command creates the following files:
The basic purpose of these files is to set up a Python package that Django can use to define the website's structure and behavior. We will discuss these files a bit more in this hour and in subsequent hours as the website gets increasingly complex. |