Free Ebook cover System creation course with Python and Django complete

System creation course with Python and Django complete

New course

176 pages

Creating a Django Project: Installing Django

Capítulo 59

Estimated reading time: 3 minutes

Audio Icon

Listen in audio

0:00 / 0:00

Django is a high-level framework, written in Python, that encourages clean web application development. It is a free and open source project with an active developer community and extensive documentation. In this chapter, we'll cover creating a Django project, starting with installing Django.

Django Installation

To start creating your Django project, the first thing you need to do is install Django in your development environment. Installation is a simple and straightforward process, which can be performed by following the steps below:

Python Installation

Django is a Python framework, so before installing Django, you need to have Python installed on your computer. If you don't have Python installed yet, you can download it from the official Python website https://www.python.org/downloads/ . Once downloaded, run the installer and follow the on-screen instructions to install Python.

Django Installation

With Python installed, you can now install Django. Django can be installed using pip, which is a package management system used to install and manage software packages written in Python.

To install Django, open a terminal and type the following command:

Continue in our app.

You can listen to the audiobook with the screen off, receive a free certificate for this course, and also have access to 5,000 other free online courses.

Or continue reading below...
Download App

Download the app

$ pip install Django

This command will download and install the latest stable version of Django. If you want to install a specific version of Django, you can specify the version after the package name. For example, to install Django version 2.2, you could use the following command:

$ pip install Django==2.2

Creating a Django Project

With Django installed, you're ready to create your first Django project. A Django project is the collection of settings and applications for a given website. A Django application is a Python module that plugs into a Django project and provides specific functionality.

To create a new Django project, open the terminal and navigate to the directory where you want to create the project. Then, use the following command:

$ django-admin startproject project_name

Replace "project_name" with the name you want to give your project. This command will create a new directory named after your project, which contains the basic structure of a Django project.

Running the Development Server

Once you've created your project, you can run the Django development server to see your project in action. The development server is a lightweight web server that serves your website pages locally - perfect for development.

To run the development server, navigate to your project directory and use the following command:

$ python manage.py runserver

This will start the development server at http://127.0.0.1:8000/. If you open this address in your browser, you'll see Django's welcome page, confirming that your project was successfully created and running.

Conclusion

In this chapter, we cover installing Django and creating a new Django project. You are now ready to start developing your site with Django. In the next chapter, we'll cover creating Django applications and the structure of a Django project.

Now answer the exercise about the content:

What is the process for installing Django and creating a new Django project?

You are right! Congratulations, now go to the next page

You missed! Try again.

The correct process involves first installing Python, as Django is a Python framework. Only after ensuring Python is installed, you proceed to install Django using the $ pip install Django command in the terminal. Finally, to create a new Django project, you utilize the command $ django-admin startproject project_name.

Next chapter

Creating a Django Project: Structure of a Django Project

Arrow Right Icon
Download the app to earn free Certification and listen to the courses in the background, even with the screen off.