Create Django Project

sapurnovdev·2022년 6월 5일


목록 보기

Initializing the Virtual Environment

  1. Create a Project folder
  2. Create Virtual Environment(inside the project folder):
python3 -m venv /path-to-venv-folder

  1. Then you have to activate the venv
    for linux
    source /path-to-venv-folder/bin/activate
    for windows
    . path-to-venv-folder/Scripts/activate
    If everything was done correctly, you should be able to see the next message in the git bash terminal:

Downloading Libraries

pip install Django

After this step, you should have the Django library in your lib folder in Virtual Environment.

Creating Django Project

To create a Django project in git bash, write this:
Make sure to do this outside of your venv folder!

django-admin startproject projectname

This command will create a Django project directory.

Basic files explanation:

  1. mysite dir is a root dir of the project.
  2. is used to run the server, make migrations, etc.
    python runserver
  3. tells python that this dir should be considered a Python package.
  4. config file for this project.
  5. URL declarations for this project.
  6. and files are for deploying this project on the server.

Run Server

Before starting your server, you should make migrations.

python migrate

Then you can run the server!

python runserver

Finally, you should see the basic Django front page if everything was done correctly.

Python, Django, AI, OCR.

0개의 댓글