Giter Site home page Giter Site logo

weather_app's Introduction

Weather_app

Create directory and .gitignore file

### Create weather_app directory
     mkdir weather_app
     
     cd weather_app/

### Venv
   
```shell
# Create environment
python3.8 -m venv --copies venv

# Activate
source venv/bin/activate

# Make sure to use venv/bin/pip3.8 
which pip3.8

Install packages

pip install Django==4.0.2

pip install psycopg2-binary==2.9.3

pip install requests==2.27.1

Create and install requirements.txt, if necessary.

pip freeze > requirements.txt

pip install -r requirements.txt

Create Django project in weather_app directory

django-admin startproject app

python manage.py startapp weather

PostgreSQL

Create database and user using docker-compose file

If in docker-compose file says:


        db:
          image: postgres
          environment:
            - POSTGRES_PASSWORD=pass
            - POSTGRES_DB=custom_db
            - POSTGRES_USER=custom_user
          ports:
            - 5432:5432

Use script to login to the database

      psql -U custom_user -h localhost custom_db
      enter password

Exit from database

exit

Django

Create static files in weather app

     weater/static/notes/css
     weater/static/notes/img
     weater/static/notes/js

Create templates in weather app

     weather/templates/notes

Edit settings.py

STATICFILES_DIRS = []

STATIC_ROOT = BASE_DIR / "staticfiles" / "static"
STATIC_URL = "/static/"

MEDIA_ROOT = BASE_DIR / "staticfiles" / "media"
MEDIA_URL = "/media/"

Edit settings.py

import os
...
DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.postgresql",
        "NAME": os.getenv('DB_NAME'),
        "USER": os.getenv('DB_USER'),
        "PASSWORD": os.getenv('DB_PASSWORD'),
        "HOST": os.getenv('DB_HOST', 'localhost'),
        "PORT": os.getenv('DB_PORT', 5432),
    }
}

collect assets

python manage.py collectstatic

...

Docker

docker system prune -a
docker-compose build --no-cache
docker-compose up -d --force-recreate
docker-compose exec app ./manage.py migrate
docker-compose exec app ./manage.py makemigrations
docker-compose exec app ./manage.py migrate
docker-compose exec app ./manage.py createsuperuser

weather_app's People

Contributors

arsenajiev avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.