Welcome to the first lesson of our course on building a TODO app using Django and Django REST Framework (DRF). In this lesson, we'll lay the foundation by setting up our development environment. A solid setup is crucial for effective and efficient development. By the end of this lesson, you will have installed the necessary libraries, created a Django project and app, and configured the basic settings and routing needed to get started.
This initial setup acts as the backbone of any Django-based project. Understanding how to configure and initialize your environment correctly is essential for the smooth development of our TODO app, which we'll build upon in future lessons.
Before we start creating our project, we need to install Django and DRF. These libraries form the core of our development environment.
To install Django and DRF, open your terminal and run the following command:
This command installs Django, a high-level Python web framework that encourages rapid development, and Django REST Framework, a powerful and flexible toolkit for building Web APIs.
Execute it in a Python virtual environment to keep your project dependencies isolated. These libraries will come pre-installed in CodeSignal's environment.
Next, we'll create a new Django project. A Django project is a collection of settings for an instance of Django, including database configuration, application-specific settings, and application initialization.
Run the following commands in your terminal:
Here's what each command does:
django-admin startproject myproject: This command creates a new directory calledmyproject, which contains the initial project structure.cd myproject: This changes your current directory tomyproject.
At this point, your project structure should look like this:
Now that we have our project, we need to create a Django app. An app is a web application that does something, like a blog system, a database of public records, or, in our case, a TODO app. A project can have multiple apps. For example, you could have apps for authentication system and main website functionality to nicely separate their logic.
Run the following command inside the myproject directory:
This command creates a new directory called myapp with the following structure:
