Giter Site home page Giter Site logo

django-rest-api's Introduction

Todo API

Python version Django version Django-RestFramework Stars Forks Commit activity

Table of Contents

Description

Todo API is an project for me to learn how to use the django in python and how to dockerize the project

Install (Run) with Docker

About the Builds and Images in use:

There are currently 3 services in use: the api (Django App), the db (the postgrSQL database), and the nginx (Nginx configuration). - api: The Django Dockerfile is in the root directory, and it has an entrypoint file that connects the backend to the database and runs migrations as well as collects the statics. - db: This is built from the postgres:13-alpine image. The default environment variables are set in the docker-compose.yml file. - nginx: The default configuration for nginx is inside the nginx folder in the nginx.conf file.

Runing Docker-Compose

  1. Clone the repo:

    git clone https://github.com/farasjibran/django-rest-api
  2. Configure the environment variables.

    1. Copy the content of the example env file that is inside the django-rest-api folder into a .env file:
      cp .env.example .env
    2. The new .env file should contain all the environment variables necessary to run all the django app in all the environments. However, the only needed variables for docker to run are the following:
      SECRET_KEY
      DB_NAME
      DB_USER
      DB_PASSWORD
      DB_HOST
      DB_PORT
    3. For the database, the default configurations should be:
      DB_NAME=db_todos
      DB_USER=todos_user
      DB_PASSWORD=todos_password!
      DB_HOST=db
      DB_PORT=5432
    4. The DOCKER_SECRET_KEY is the django secret key. To generate a new one see: Stackoverflow Link
  3. Run docker-compose:

    docker-compose up --build
  4. Congratulations =) !!! The App should be running in localhost:80

  5. (Optional step) To create a super user run:

    docker-compose run api ./manage.py createsuperuser

Installation without Docker

  1. Clone the repo:

    git clone https://github.com/farasjibran/django-rest-api
  2. Configure a virtual env and set up the database. See Link for configuring Virtual Environment and Link for Database setup.

  3. Configure the environment variables.

    1. Copy the content of the example env file that is inside the django-rest-api folder into a .env file:
      cp .env.example .env
    2. The new .env file should contain all the environment variables necessary to run all the django app in all the environments. However, the only needed variables for the development environment to run are the following:
      SECRET_KEY
      DB_NAME
      DB_USER
      DB_PASSWORD
      DB_HOST
      DB_PORT
    3. For the database, the default configurations should be:
      DB_NAME=todo_app
      DB_USER=postgres
      DB_PASSWORD=
      DB_HOST=localhost
      DB_PORT=5432
    4. The SECRET_KEY is the django secret key. To generate a new one see: Stackoverflow Link
  4. Run the migrations and then the app:

    python manage.py migrate
    python manage.py runserver
  5. Congratulations =) !!! The App should be running in localhost:8000

  6. (Optional step) To create a super user run:

    python manage.py createsuperuser

Useful Links

Postgresql Databse

Docker

Django and DRF

Miscellaneous

django-rest-api's People

Stargazers

Muhammad Farras Jibran avatar

Watchers

Muhammad Farras Jibran 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.