- Install Python
sudo add-apt-repository ppa:jonathonf/python-3.6
sudo apt-get update
sudo apt-get install python3.6
- Create a folder djnago-handson
mkdir djnago-handson
- Install Pipenv
pip install pipenv
- Move to the directory where you have create django-workshop folder
cd /home/rupesh/djnago-handson
- Create pipenv virtual environment and initialise pipenv
# Creates virtual environment using python 3.6
pipenv install --python 3.6
- Activate pipenv virtual environment
pipenv shell
- List all the python packages installed in the virtual environment
pip list
- Install django in the virtual environment
pipenv install django==2.2
- Check if django installed correctly
pip list
- Create a new Django project
django-admin startproject worldcup
- Check the project folder
ls -larth
- Start Django server
python manage.py runserver OR python manage.py runserver 8080
- Create App in Django
python manage.py startapp simpleapp
- Create another app 'players'
python manage.py startapp players
- Make migrations
python manage.py makemigrations
- Check migrations in SQL
python manage.py sqlmigrate players 0001
- Migrate to database
python manage.py migrate
SQLLite browser
sudo apt-get update
sudo apt-get install sqlitebrowser
SQLLite installation
sudo apt-get install sqlite3 libsqlite3-dev
Create Superuser for Admin
python manage.py createsuperuser
Extra commands;
Get pipenv python environment
pipenv run which python
pipenv --venv
Uninstall package
pipenv uninstall packageName
```;
Clean environment and removed the uninstalled packages from the environment
pipenv clean
Remove virtual environment created by pipenv
```python
pipenv -rm
Lock pipfile
pipenv Lock
Project Home folder
pipenv --where
Deactivate Virtual Environment
exit
Start Django Shell
python manage.py shell
SQL query for migrations
python manage.py sqlmigrate <appname> <migration number eg. 0001 or 0004>
Add migrations manually
python manage.py makemigrations --name migration_name app_ame --empty