Skip to content

danyi1212/drf-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Django Rest Framework project boilerplate

GitHub release (latest by date) GitHub all releases GitHub Release Date

Boilerplate for quickly creating a DRF projects and apps.

  • Pre-configured with logging, swagger, global access conditions, and JWT authentication.
  • App template including signals, urls (with router), serializer, and background tasks.
  • Users application implementing custom model, serializer, and view set for user (with history).
  • Included PyCharm run configurations for runserver, shell, and mockup data export/import.

Links

Included Technologies

Usage

New Project

Create a new folder with the name of your Django project, open a terminal in it and run:

Note: You may want to install the pip packages manually to install specific versions of packages.

Click to expand
pip install django ipython docutils django-debug-toolbar django-cors-headers django-simple-history django-background-tasks djangorestframwrork django-filter drf-yasg djangorestframework-simplejwt drf-access-policy
$ git init
$ python -m venv venv
$ ./venv/Scripts/activate
(venv) $ pip install -r https://git.io/JOM5l
(venv) $ django-admin startproject <project_name> . --template https://git.io/JOM5X
(venv) $ py manage.py migrate

Notice: It is advised to create a requirements.txt file to store your project's dependencies.

Click to expand
pip freeze > requirements.txt

Notice: To use the included PyCharm run configurations, rename the _run folder to .run.

Click to expand
mv _run .run

New App

Open a terminal, activated with the project's virtual environment and run:

(venv) $ py manage.py startapp <app_name> --template https://git.io/JOM5y

Add your app to the INSTALLED_APPS setting in your settings.py file:

INSTALLED_APPS = [
    # Project apps
    "<app_name>",
]

Include the app's router in your projects urls.py file:

urlpatterns = [
    # Project app routers
    path("<app_name>/", include("<app_name>.urls")),
]

PyCharm Run Configurations

This boilerplate includes PyCharm Run Configurations for:

  • runserver - Starts a lightweight Web server for development and also serves static files.
  • process_tasks - Run tasks that are scheduled to run on the queue.
  • shell - Runs a Python interactive interpreter (using IPython, with PyCharm debug mode).
  • export mockup - Export model data to mockup.json using dumpdata (used for mockup data).
  • import mockup - Import model data from mockup.json using loaddata (used for mockup data).
  • test - Discover and run tests in your project.