boobo94 / boobo94.github.io

My personal website.
https://whyboobo.com
MIT License
3 stars 1 forks source link

Create django project #38

Closed boobo94 closed 2 years ago

boobo94 commented 2 years ago

Create a virtual environment

How to install Django official documentation.

Use .venv, the tool provides isolated Python environments, which are more practical than installing packages systemwide. It also allows installing packages without administrator privileges.

start venv

source demo-env/bin/activate

exit from venv

deactivate

Install dependencies

Create a requirements.txt file where to add all dependencies, make sure you already started the venv.

pip install -r requirements.txt

Create a new project

execute the following command to create the base app. [Official doc]

 django-admin startproject YOUR_PROJECT_NAME

*Replace YOUR_PROJECT_NAME with your desired name for the projecte.

After the execution a new folder will be created having the name YOUR_PROJECT_NAME.

Run server

python manage.py runserver

Create new app

python manage.py startapp polls

Create migrations

python manage.py makemigrations

Execute migrations

python manage.py migrate

Create an admin user

python manage.py createsuperuser

Then insert the username and password.