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.
Django REST framework is a powerful and flexible toolkit for building Web APIs.
Some reasons you might want to use REST framework:
- Utilized by developers for rapid development
- The Web browsable API is a huge usability win for your developers.
- Authentication policies including optional packages for JWT-Auth.
- Serialization that supports both ORM and non-ORM data sources.
- Customizable all the way down - just use regular function-based views if you don't need the more powerful features.
- Extensive documentation.
You should have the following for this setup:
- Python 3.8+
- Django 5.0, 5.1+
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
$ git clone: https://github.com/pride-land/backend-pride-land
$ cd backend-pride-land
$ python3 -m venv .venv
$ source .venv/bin/activate
$ pip install django
$ python3 manage.py runserver
$ pip install djangorestframework
$ pip install django-cors-headers
$ pip install psycopg2-binary
$ pip install python-dotenv
$ pip install djangorestframework-simplejwt
$ pip install Pillow
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',
]
}
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'prideland',
'USER': 'postgres',
'PASSWORD': 'your_password',
'HOST': 'your_localhost',
'PORT': 'your_localport',
}
DB_USER = "DB_USER"
DB_PASS = "DB_PASS"
DATABASE_URL = "DB_URL"
ALLOWED_HOSTS = ['*']
SECRET_KEY = "SECRET_KEY"