-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinfo.txt
39 lines (30 loc) · 2.07 KB
/
info.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
python -m venv virt // to setup virtual env
virt/Scripts/activate // to activate the virtual environment
pip install django // to install django
pip install mysql // to install mysql
pip install mysql-connector-python // connection to mysql
django-admin startproject imcrm // to create/template django project
python manage.py startapp website // to create an app (smaller component of a project)
inside the app, we created (in this case, called website), we can create static named folder to serve static files such css, js or images
add the app you just created (website) in settings.py, change database to mysql
python mydb.py // to check for the database connection
go to mysql workbench and now refresh the schemas! you can find your schema there
python manage.py migrate // after connecting to database, we need to push it into django
winpty python manage.py createsuperuser // to create a superuser or admin
python manage.py runserver // to run the server
NOTE: before running the server, click on the run button in the manage.py file, this will activate the virtual environment, then navigate into dir with manage.py and then
python manage.py
OR
do it the programmers way
.\virt\Scripts\activate // this command in the root dir will activate the virtual environment
then cd into the dir with the main file and // python manage.py runserver // voila!
NOTE: we can always add new users through the django admin panel, for small projects, this will do
but here, we can look at manual ways to register users (preferring the django method though!)
NOTE: whenever we do some database stuff, we must always
python manage.py makemigrations (this must be done in the parent dir which contains our app, in this case, website)
then,
python manage.py migrate
pip freeze > requirements.txt // whenever we are trying to dockerize, and if we want to create a requirements.txt file,
whenever we have multiple docker containers (the server, the application etc), it is better to work with docker compose
after writing the docker compose and making sure docker-desktop is running,
in terminal, docker-compose build