Git Product home page Git Product logo

graph's Introduction

graphene-django library

This is a follow along project from DjangoCon 21 with Dane Hillard.

I have been exploring GraphQL as the most viable framework for a complex relational memory structure. This type of memory structure would have (k) applications in real world data management and graphQL's easy endpoint is super enticing. This is a minimal example of a graph implementation.

I did modify the project as shared by Dane using some of my own best-practices. I used `python-dotenv` for storing secrets and also added an authentication layer in the query using the `info.context.user.is_authenticated` from `info` given to the query.

Project Setup

Requirements.txt

A few of these came through with other packages. The important packages to reference here are:

python-dotenv, psycopg2-binary and graphene-django

  1. aniso8601==9.0.1
  2. asgiref==3.6.0
  3. Django==4.2
  4. graphene==3.2.2
  5. graphene-django==3.0.0
  6. graphql-core==3.2.3
  7. graphql-relay==3.2.0
  8. promise==2.3
  9. psycopg2-binary==2.9.6
  10. python-dotenv==1.0.0
  11. six==1.16.0
  12. sqlparse==0.4.4
  13. text-unidecode==1.3
  14. tzdata==2023.3

settings.py imports

  from pathlib import Path
  from dotenv import load_dotenv
  import os
  load_dotenv()

settings.py backend db setup:

  DATABASES = {
    'default': {
    'ENGINE': 'django.db.backends.postgresql_psycopg2',
    'NAME': os.environ.get('DB_NAME'),
    'USER': os.environ.get('DB_USER'),
    'PASSWORD': os.environ.get('DB_PASSWORD'),
    'HOST': os.environ.get('DB_HOST'),
    'PORT': '',
    }
  }

I use Postgres for most projects.

Static Files

  STATIC_URL = "/static/"
  # Set the STATIC_ROOT setting to a valid filesystem path where Django can collect static files
  STATIC_ROOT = os.path.join(BASE_DIR, 'collected_static')

  MEDIA_URL = '/media/'
  MEDIA_ROOT = os.path.join(BASE_DIR, 'static/media')

  STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static')
  ]

Graphene Schema reference in settings.py:

  GRAPHENE = {
    "SCHEMA": "schema.schema",
  }

graph's People

Contributors

jiwallin3 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.