Fast start application Django

Project Structure

├── django/
├── [project_name]/
├── apps/
├── [app1_name]
├── admin.py
├── apps.py
├── models.py
├── serializers.py
└── views.py
├── setting.py
├── api_urls.py
├── manage.py
├── scripts/
├── startapp.sh
├── generate.sh
  1. Create a directory for storing the script.
mkdir scripts && cd scripts

2. Create startapp.sh to create an application in the project.

touch startapp.sh

3. Install drf-generators and follow the Installation of a document

$ pip install drf-generators

To use DRF Generators, add your INSTALLED_APPS.

INSTALLED_APPS = (
...
'rest_framework',
'drf_generators',
...
)

4. Create generate.sh to generate serializers.py and views.py for your application.

5. Try creating a new application by run the command startapp.sh

$ bash scripts/startapp.sh <app name>

6. Writing model your new application.

in settings.pyLOCAL_APPS = [
...
'main.apps.products',
]

and run python manage.py makemigrations && python manage.py migrate then new file migration.

7. run the command generate.sh

$ bash scripts/generate.sh <app name>

8. Add Viewset in api_urls.py

from main.apps.products.views import ProductViewSet


router = DefaultRouter()
app_name = 'api_urls'

# Register your API router here. It should be sorted by alphabet

router.register('products', ProductViewSet)

9. Finally. I get it.

--

--

--

Software development

Love podcasts or audiobooks? Learn on the go with our new app.

Rapid iOS UI Design and Prototyping With Swift Playgrounds

BUSINESS AS THE DRIVER

My journey becoming a Unity game developer: Audio Manager: Intro Cutscene Camera Fix and Skip Intro

Disable SELinux on CentOS 7 or CentOS 8

2019: Ethereum Full Node Setup

How To Write Beautiful React Code

Integrating AWS APIs in Python — Using AWS S3 with the boto3 SDK

Engineer to Engineer: Creating Career Through Fearless Connections

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jane Ratthanan

Jane Ratthanan

Software development

More from Medium

Automation And Django Debug

Things to keep in mind when hosting and configuring a Django application[!!!SELF NOTE!!!]

A Django Todo app — learn from scratch

How to create a contact form in django in Django