Skip to content

pride-land/backend-pride-land

Repository files navigation

Pride-Land · PRs Welcome GitHub license Python DjangoREST Static Badge JWT Static Badge Gunicorn Render

Introduction

Prideland a non-profit organization with a mission to create a society in which everyone, regardless of whether they are able-bodied or disabled, can work freely as they are by respecting their different physical, intellectual, and mental conditions and by giving appropriate consideration to each other.

Overview

Django REST framework is a powerful and flexible toolkit for building Web APIs.

Some reasons you might want to use REST framework:

Requirements

You should have the following for this setup:

  • Python 3.8+
  • Django 5.0, 5.1+

Setting up Development

Here's a quick guide and run down on how to setup environment and start developing the project. Make sure to add a .env file that has DB_USER and DB_PASS

Initial Setup:

$ git clone: https://github.com/pride-land/backend-pride-land
$ cd backend-pride-land

Quick start:

$ python3 -m venv .venv
$ source .venv/bin/activate
$ pip install django
$ python3 manage.py runserver

App or Dependencies installed:

$ pip install djangorestframework
$ pip install django-cors-headers
$ pip install psycopg2-binary
$ pip install python-dotenv
$ pip install djangorestframework-simplejwt
$ pip install Pillow

Example

Let's take a look at a quick example of using REST framework to build a simple model-backed API for accessing users and groups.

Startup up a new project like so...

pip install django
pip install djangorestframework
django-admin startproject example .
./manage.py migrate
./manage.py createsuperuser

We'd also like to configure a couple of settings for our API.

Add the following to your settings.py module:

INSTALLED_APPS = [
    ...  # Make sure to include the default installed apps here.
    'rest_framework',
]

REST_FRAMEWORK = {
    # Use Django's standard `django.contrib.auth` permissions,
    # or allow read-only access for unauthenticated users.
    'DEFAULT_PERMISSION_CLASSES': [
        'rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly',
    ]
}

Postgresql as database.

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'prideland',
        'USER': 'postgres',
        'PASSWORD': 'your_password', 
        'HOST': 'your_localhost',
        'PORT': 'your_localport',
    }

for .env file settings:

DB_USER = "DB_USER"
DB_PASS = "DB_PASS"
DATABASE_URL = "DB_URL"
ALLOWED_HOSTS = ['*']
SECRET_KEY = "SECRET_KEY"

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •