Categories: Web tips and tricks

Everything you need to know about Django

To build web applications with Django, it is essential to have Python installed on your machine beforehand. However, having Python installed is not enough, you also need to install Django, write a few lines of code and run the application with Django. How do I get started with Django?

Norton Secure VPN 2023 for up to 5 Devices
19,99 $

Requirement

  • An internet connection
  • The basics of Python
  • Good judgement
  • A minimum of concentration and attention
  • Knowledge of the command prompt

Getting started with Django

Before we get started, do you have what you need to get started with Django? If so, let’s get down to business.

  • Open a terminal: move to the directory where you want to create your Django project
  • Once in that directory, create a virtual environment and activate it
  • Install Django by entering the command “pip install Django
  • Save the new packages in the “requirements.txt” file with the “pip freeze > requirements.txt” command

NB : your virtual environment must be activated, also make sure you are in the root directory where your virtual environment is located, also respect the spaces between the words of the commands.

You will notice that there are changes in the base directory of your project; open it for example with your integrated development environment to see the changes. You will see a tree structure similar to this

Now we have to check that our application is running,

  • Go to the mysite sub-directory and type the command

You will get an output similar to the image below in your command prompt

  • Go to the doc

By default, Django comes with an authentication system and many other features. We therefore need to create the corresponding databases for this authentication system through what are called migrations.

  • Run the command

Django works with a set of mini applications for a single project; it’s time to generate our first mini application

  • Then run the command
  • Fill in the mini application in settings.py as shown here:

If you wish to configure a DBMS other than SQLite which is delivered with Django, go to the mysite subdirectory, then in settings configure the new DBMS you wish to use by modifying parameters such as ENGINE, NAME, USER, PASSWORD, HOST. For the database you are going to use, go to the official documentation to find out how to configure it.

You have everything you need to start creating templates and returning data from these templates using a view. For the creation of models and views, please read the documentation, or follow this course.

Find out about :

Partager

Post Récent

TakeTako: the app that’s revolutionizing travel in Cameroon

TakeTako is an application developed by TakeTako SAS, an innovative transport technology start-up. The TakeTako app was born out of…

il y'a 2 months

How to take a screenshot directly in Word

Screenshot is an essential feature for illustrating and documenting information in a Word document. Did you know that you can take…

il y'a 4 months

Nothing Phone (2a) vs. Nothing Phone (1): Major changes

Since the release of its first model in 2022, Nothing has come an impressive distance in the smartphone field. With the…

il y'a 4 months

Nothing Phone (2a) vs Nothing Phone (2)

Nothing announced its latest addition, the Nothing Phone (2a), eyes immediately turned to its high-end predecessor, the Nothing Phone (2). With…

il y'a 4 months

Nothing Phone (2a) vs Google Pixel 7a: Which is right for you?

A new phone arrives in an Android universe filled with competition, the Nothing Phone (2a) joins an already dense competition. Among…

il y'a 4 months

Common Google Pixel Fold problems and solutions

ixel Fold screen issues Top speaker not working when phone is unfolded Pixel Fold overheating issue Google Pixel Fold not…

il y'a 4 months