Start Django Project - koglak/SWE573 GitHub Wiki

Required Installations:

Write below command to cmd!

 pip install Django==3.2.10

Start Project

1) First of all, create new file by using cmd! It is important that special characters should not be in your path!

Go to the directory that you will create your project!

cd C:\Users\kogla\Documents

Create your new directory!

mkdir swe573

Go to new directory!

cd swe573

2) Establish Virtual Environment

Crete your venv inside your project directory!

venv (for Python 3) and virtualenv (for Python 2) allow you to manage separate package installations for different projects. They essentially allow you to create a “virtual” isolated Python installation and install packages into that virtual installation.

python -m venv myvenv

image

3) Install Django!

Create a new requirements.txt file in your project directory!

Put below lines inside requirements.txt and save it!

Django~=3.2.10

Write below line in your cmd and install Django!

pip install -r requirements.txt

4) Activate your virtual environment!

myvenv\Scripts\activate

5) Create your new Django Project!

django-admin.exe startproject mysite .

image

6) Go to your setting.py file and add & update below lines.

 LANGUAGE_CODE = 'tr-TR'

 STATIC_URL = '/static/'
 STATIC_ROOT = BASE_DIR / 'static'

 ALLOWED_HOSTS = ['127.0.0.1', '.pythonanywhere.com']

7) Create a database!

 python manage.py migrate

8) Start web-service!

 python manage.py runserver

9) Your website is ready!

Copy the localhost address and paste to your web browser!

10) How to stop web service?

If you click Ctrl+C in your terminal, you can stop service.

11) How to deactivate virtual environment?

Write below comment to your terminal!

 deactivate