DEV Community

Cover image for How to Create a Django Project and Application.
chryzcode
chryzcode

Posted on • Edited on

How to Create a Django Project and Application.

Introduction.

This article is a guide on how to create your (first) Django project and application.

A Little about Django.

The web framework for perfectionists with deadlines.

Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. Built by experienced developers, it takes care of much of the hassle of web development, so you can focus on writing your app without needing to reinvent the wheel. It’s free and open source.

Copied from the Django official website.

Interested in reading a little about Python, check out one of my articles The Language: Python.

Get started

Prerequisites and Requirements

Here are the prerequisites and requirements to get started in creating your Django application :

  • Install Python.

    Paste this command on your terminal. The command below is to verify if you have Python properly installed. It should provide the version of Python you installed.

    python --version
    
  • Install Django.

    The same thing applies to Django.

    django-admin --version
    

Create a Django Project.

I believe you have Python and Django installed. Navigate to the directory of your choice on your terminal, desktop is my choice of directory for my new Django project

cd desktop
Enter fullscreen mode Exit fullscreen mode

and paste the command below to create your project, my_project is the name of my Django project.

django-admin startproject my_project
Enter fullscreen mode Exit fullscreen mode

To check the files or folders in your project

#for MacOS
ls my_project

#for Windows
dir my_project
Enter fullscreen mode Exit fullscreen mode

Create a Django Application

To create your Django application copy and paste the command below on your terminal to change your directory to the newly created project.

#to change directory
cd my_project

#to create a django app
django-admin startapp my_app
Enter fullscreen mode Exit fullscreen mode

Note: It is possible to have multiple applications based on the scope of the project.

Run and Test the Django Project

To check if our Django project is up and running, paste this code below on your terminal. The command is to run your server(app/project) locally.

python manage.py runserver
Enter fullscreen mode Exit fullscreen mode

If the image below is the same as yours, then you have successfully created your Django project/ application.

The warning about unapplied migrations is related to the database which will not be covered.

Image description

To view the locally hosted project on your browser, click this link http://127.0.0.1:8000/. This is the local server link to your Django application and this should be the view of your project on the browser.

Image description

Congratulations on creating your (first) Django application.

Continuation...

Top comments (0)