Giter VIP home page Giter VIP logo

cookie-api-v2's Introduction

Cookie Stand Api V2

Author: Davee Sok

Links & Resources

Overview/ Motivation

Create a Cookie Stand API

Tools & Dependencies

  • Django
  • Django Rest Framework
  • Black
  • Docker
  • psycopg2-binary

Commands To Know

docker-compose up
docker-compose run web python manage.py makemigrations
docker-compose run web python manage.py migrate
docker-compose run web python manage.py createsuperuser
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser

Docker

docker-compose -d
docker-compose up
docker-compose up --build
docker-compose down
docker-compose stop
docker-compose start
docker-compose restart
docker-compose logs

Httpie Commands through terminal

# This signs us in and grabs access and refresh tokens
http POST :8000/api/token/ username='[email protected]' password='admin'

# This adds our access token to the headers in our request. Gets all blogs
http GET :8000/api/v1/blog/ 'Authorization: Bearer ADD_ACCESS_TOKEN_HERE'

# Gets One Item with pk=4
http GET :8000/api/v1/blog/4 'Authorization: Bearer ADD_ACCESS_TOKEN_HERE'

# Deletes One Item with pk=3
http DELETE :8000/api/v1/blog/3 'Authorization: Bearer ADD_ACCESS_TOKEN_HERE'

Other

poetry export -f requirements.txt -o requirements.txt --without-hashes
python manage.py collectstatic -> whitenoise command to add static files

Extra Notes

This project makes use of a custom user that over writes django's default user model. When you create new models that need to reference user as a foreign key, you need to make the following changes:

# Old Way

from django.contrib.auth import get_user_model

class Post(models.Model):
    author = models.ForeignKey(get_user_model(), on_delete=models.CASCADE)

# ----------------------------------- New Way -----------------------------------

from django.conf import settings

class Post(models.Model):
    author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)

In your tests, you would still use get_user_model()

cookie-api-v2's People

Contributors

davees987 avatar dependabot[bot] 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.