Thursday, March 7, 2019

Prepare your machine for django development


sudo apt-get update
sudo apt-get install python3-pip
sudo pip3 install django
django-admin --version

django-admin startproject projectname
cd projectname
python3 manage.py makemigrations
python3 manage.py migrate

python3 manage.py createsuperuser

python3 manage.py startapp NewApp
python3 manage.py makemigrations NewApp
python3 manage.py migrate

nano ~/projectname/projectname/settings.py
         ALLOWED_HOSTS = ['your_server_domain_or_IP']

python3 manage.py runserver 0.0.0.0:8000

Run http://127.0.0.1:8000/admin to see django start admin page

Notes:
To create a shortcut command ie p3 for python3
alias p3=python3

To get the default mysql port run the sql command
mysql> SHOW VARIABLES WHERE Variable_name = 'port';

Add privileges to new user
GRANT ALL ON *.* TO root@'202.54.10.20' IDENTIFIED BY 'PASSWORD';

when change any python file reload the application using command

service apache2 reload

1 comment:

Nathan Duference said...

I read over your blog, and I found it inquisitive. Also, you may also find Django Development Company Interested.