Django/Beginner: Difference between revisions

From Chorke Wiki
Jump to navigation Jump to search
(Created page with "==Configuration== <source lang="bash"> sudo -H pip3 install --upgrade pip sudo -H pip3 install virtualenv </source> ==Virtualization== <source lang="bash"> sudo su cd /opt/dj...")
 
 
(7 intermediate revisions by the same user not shown)
Line 35: Line 35:
python manage.py runserver 192.168.1.110:8000
python manage.py runserver 192.168.1.110:8000
deactivate
deactivate
</source>
==Start App==
<source lang="bash">
python manage.py startapp myapp
ls -la myapp
</source>
==Good To Know==
<source lang="bash">
a2enmod wsgi
a2dismod wsgi
apache2ctl -t
apache2ctl -M
systemctl status apache2
systemctl enable apache2
systemctl restart apache2
virtualenv venv --python=python3.6
source venv/bin/activate
sudo chown -R www-data:www-data /opt/env/python/RestApi
sudo chown -R www-data:www-data /opt/www/flask/RestApi
nohup python RestApi/RestApi/__init__.py>RestApi.log &
ssh -L 5000:localhost:5000 [email protected]
apt install net-tools
ss -lptn 'sport = :5000'
netstat -nlp | grep :5000
</source>
</source>


==References==
==References==
* [[DigitalOcean Reverse Proxy]]
* [[Python/Distribution|Python Build Distribution]]
* [https://www.django-rest-framework.org/tutorial/quickstart/ Django Rest Framework]
* [https://www.python.org/downloads/release/python-360/ Download Python 3.6.0]
* [https://www.python.org/downloads/release/python-360/ Download Python 3.6.0]
* [https://www.python.org/downloads/release/python-350/ Download Python 3.5.0]
* [https://www.python.org/downloads/release/python-350/ Download Python 3.5.0]
* [https://docs.djangoproject.com/en/2.1/topics/migrations/ Django 2.1 Migrations]
* [https://docs.djangoproject.com/en/2.1/topics/migrations/ Django 2.1 Migrations]
* [https://docs.djangoproject.com/en/2.1/ref/settings/ Django 2.1 Settings]
* [https://docs.djangoproject.com/en/2.1/ref/settings/ Django 2.1 Settings]

Latest revision as of 23:06, 2 August 2022

Configuration

sudo -H pip3 install --upgrade pip
sudo -H pip3 install virtualenv

Virtualization

sudo su
cd /opt/django/www
python3 -m venv myenv
source myenv/bin/activate

Installation

pip install django
django-admin startproject myrpi

Settings

# nano myrpi/settings.py
ALLOWED_HOSTS = [
    'localhost',
    '192.168.1.110',
    '192.168.1.111'
]

Run Server

python manage.py migrate
python manage.py makemigrations
python manage.py runserver 192.168.1.110:8000
deactivate

Start App

python manage.py startapp myapp
ls -la myapp

Good To Know

a2enmod wsgi
a2dismod wsgi

apache2ctl -t
apache2ctl -M

systemctl status apache2
systemctl enable apache2
systemctl restart apache2

virtualenv venv --python=python3.6
source venv/bin/activate

sudo chown -R www-data:www-data /opt/env/python/RestApi
sudo chown -R www-data:www-data /opt/www/flask/RestApi

nohup python RestApi/RestApi/__init__.py>RestApi.log &
ssh -L 5000:localhost:5000 [email protected]

apt install net-tools
ss -lptn 'sport = :5000'
netstat -nlp | grep :5000

References