Skip to content

Experimental - Web development using Django framework

Notifications You must be signed in to change notification settings

oWahyudi/commerce

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Commerce - Django

Experimental - Web development using Django framework

Note

Exercise:
Model, ModelForm, ModelAdmin, ListView, Pagination, CSS Flex
SQLlite, Nginx

  1. Create virtual environment

    python3 -m venv django-env

  2. Activate virtual environment

    source django-env/bin/activate

  3. Install requirement

    pip install -r requirement.txt

  4. Create Django Project

    django-admin startproject <PROJECT_NAME>

  5. Run Django application (webserver)

    python manage.py runserver (default port 8000)
    python manage.py runserver 8001 (run at port 8001)

  6. Create Django apps

    stop webserver (CTR-C)
    python manage.py startapp
    Configure into INSTALL_APP in setting.py (in Django admin Project folder)
    Create urls.py in folder
    Configure path into URLPATTERN in urls.py (in Django admin project folder)

  7. Create default Session table.

    python manage.py migrate (in Django admin project root folder)

Nginx - Configure Nginx as a web server to host image files from an auction platform

  1. Install Nginx

    brew install nginx

2a. start nginx manually > nginx

2b. start nginx automatically ( install as service) > brew services start nginx

  1. Verify nginx instalation, browse http://localhost

  2. Configuration file path "/usr/local/etc/nginx/" Default webroot path "/usr/local/var/www/"

5a. Stop nginx manually > nginx -s stop

5b. Stop nginx (if installed as service) > brew services stop nginx

  1. Restart nginx

    brew services restart nginx or restart nginx

Configure nginx as file server

  1. Create a local nginx local configuration file

    mkdir /Users/dummyuser/myfolder/nginx.conf


server {
listen 8181;
server_name localhost;

# Location for favicon
location = /favicon.ico { 
   access_log off; 
   log_not_found off; 
}


# Serve media files directly
location /media/ {
   alias /Users/dummyuser/files/commerce/media/;
   expires 30d;
}

# Proxy other request to Gunicorn server
# URL for website that consme images files 
location / {
   proxy_pass http://127.0.0.1:8000;   
   proxy_set_header Host $host;
   proxy_set_header X-Real-IP $remote_addr;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
   proxy_set_header X-Forwarded-Proto $scheme;
}


}
  1. Include your local nginx.conf to /usr/local/etc/nginx/nginx.conf
.
.
.
http {
    
    #include to local nginx.conf path
    include /Users/dummyuser/myfolder//nginx.conf;
.
.
.

About

Experimental - Web development using Django framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published