Skip to content

Latest commit

 

History

History
176 lines (149 loc) · 3.01 KB

Setup.md

File metadata and controls

176 lines (149 loc) · 3.01 KB

Setup

Virtual Environment :


virtualenv package is recommended!


Installation:

pip install virtualenv

Setup:

# this will create a virtualenv directory named source
virtualenv source

Activate:

# get source directory
cd source

# this will activate it on windows:
scripts\activate

# this will probably activate it for another OS:
# (source is a command/not related with the name of the virtual environment/it's just coincidence):
source bin/activate

(for further information: https://virtualenv.pypa.io/en/latest/user_guide.html#activators)

Output should be:

# source virtualenv activated
(source) C:\...\source>

Django :


Django 3.2.12 is used!


Installation:

# (source) C:\...\source>
pip install django

Setup project:

# (source) C:\...\source>
django-admin startproject music_app

(for further information: https://docs.djangoproject.com/en/4.0/intro/tutorial01/)

Output should be:

# for source/music_app
│   manage.py
│
└───music_app
        asgi.py
        settings.py
        urls.py
        wsgi.py
        __init__.py

Setup Django apps:

# (source) C:\...\source\music_app>
python manage.py startapp music
python manage.py startapp user
python manage.py startapp playlist

Output should be:

# for source/music_app
│   manage.py
│
├───music
│   │   admin.py
│   │   apps.py
│   │   models.py
│   │   tests.py
│   │   views.py
│   │   __init__.py
│   │
│   └───migrations
│           __init__.py
│
├───music_app
│   │   asgi.py
│   │   settings.py
│   │   urls.py
│   │   wsgi.py
│   │   __init__.py
│   │
│   └───__pycache__
│
├───playlist
│   │   admin.py
│   │   apps.py
│   │   models.py
│   │   tests.py
│   │   views.py
│   │   __init__.py
│   │
│   └───migrations
│           __init__.py
│
└───user
    │   admin.py
    │   apps.py
    │   models.py
    │   tests.py
    │   views.py
    │   __init__.py
    │
    └───migrations
            __init__.py

Adding Django adds to music_app/settings.py installed apps:

# Before ---------------
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]
# ----------------------

# After ----------------
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

    # django apps
    'music',
    'playlist',
    'user',
]
# ----------------------

Make migrations:

# (source) C:\...\source\music_app>
python manage.py makemigrations
python manage.py migrate

Create superuser:

# (source) C:\...\source\music_app>
python manage.py createsuperuser