Tuesday, 21 April 2020

Python Django cheat sheet and Quick Hacks feat. Zappy Code on Udemy

If you have opted for django course on Udemy from zappy code ( Nick Walter )  and directly downloaded the producthunt repository from github, without anything installed on your local machine , here are steps you can follow to set up your machine to run the project.


Steps to follow when working with producthunt repository for Nick walter Django udemy course:

1 ) install django :
python -m pip install django

2) verify django :
django-admin --version

3) running a django project :
go to project directory where manage.py is present :

>> python manage.py runserver

there would be many errors we would work on solving this errors

4) install postgres on your machine :
pip install psycopg2-binary

5) then you also need to install postgres.exe on your windows machine
during installation remember the user.

for zappy code project
username was postgres
password was django1234
keep same password to avoid confusion.

link : https://www.postgresql.org/download/

log in in SQL shell using the same user you created.
In windows type : SQL shell to search it

6) To create database in SQL use following command in console :
CREATE DATABASE database_name;

In our case : CREATE DATABASE portfoliodb;

7) to install pillow 
pip install pillow

8) local server is at :
http://127.0.0.1:8000/

9) django admin can be found at:
http://127.0.0.1:8000/admin

10) To log in to admin create superuser for admin :
python manage.py createsuperuser

--------------------------------------------------------------------------

Django cheat sheet @courtsy zappy code :


Creating a new project
django-admin startproject projectname

Add an app to a project
python3 manage.py startapp appname

Starting the server
python3 manage.py runserver

Creating migrations
python3 manage.py makemigrations

Migrate the database
python3 manage.py migrate

Creating a Super User for the admin panel
python3 manage.py createsuperuser

Collecting static files into one folder
python3 manage.py collectstatic

To open django shell
python3 manage.py shell

To exit shell
exit()

Help menu
django-admin help

Allauth:

default installation : 
C:\Users\<user_name>\AppData\Local\Continuum\miniconda3\lib\site-packages\allauth\account\ >


No comments:

Post a Comment