/django-dynamic-services

Django Dynamic Services - Open-Source Project | AppSeed

Primary LanguageHTMLOtherNOASSERTION

Open-source Django project that showcases the API Generator and other Dynamic Services - actively supported by AppSeed.

👉 Django - Build Services without Coding - video presentation (learn how to use this starter)

Features


Django Dynamic Services - free developer tools provided by AppSeed.


Start the app in Docker

👉 Step 1 - Download the code from the GH repository (using GIT)

$ git clone https://github.com/app-generator/django-dynamic-services.git
$ cd django-dynamic-services

👉 Step 2 - Start the APP in Docker

$ docker-compose up --build

Visit http://localhost:5085 in your browser. The app should be up & running.

👉 Step 3 - Create Superuser in Docker

$ # List containes & get the ID
$ docker container ls  
$ # Create the superuser
$ docker exec <CONTAINER_ID> python manage.py createsuperuser 

Manual Build

👉 Download the code

$ git clone https://github.com/app-generator/django-dynamic-services.git
$ cd django-dynamic-services

👉 Install modules via VENV

$ virtualenv env
$ source env/bin/activate
$ pip install -r requirements.txt

👉 Set Up Database

$ python manage.py makemigrations
$ python manage.py migrate

👉 Generate API

$ python manage.py generate-api     # requires confirmation
// 
$ python manage.py generate-api -f  # no input (API folder is overwritten)

👉 Create the Superuser

$ python manage.py createsuperuser

👉 Start the app

$ python manage.py runserver

At this point, the app runs at http://127.0.0.1:8000/ and the generated API can be found at:

The default API nodes can be tested via this POSTMAN Collection.


How to use the API

  • Start the app
  • Make sure the endpoints are up & running
  • Authenticate via API and het the access token
    • http://localhost:8000/login/jwt/ usind existing credentials
    • Save the token in the requests HEADER
  • GET Requests are public (no token required)
    • GET ALL products: http://localhost:8000/api/product/
    • GET product by ID: http://localhost:8000/api/product/1/
    • GET ALL Sales: http://localhost:8000/api/sales/
  • Create, Delete, Update requires a token in the header

For API sample requests, open and edit the POSTMAN Collection sample.


How Update the API

  • Define or update your models
  • Migrate the database
  • Update the configuration API_GENERATOR section
  • Regenerate the API
    • python manage.py generate-api

At this point, you should be able to use the API. For more information regarding the library used to generate the code, access:

👉 API Generator for Django - Open-Source Library


Codebase structure

The project is coded using a simple and intuitive structure presented below:

< PROJECT ROOT >
   |
   |-- core/                            
   |    |-- settings.py                  # Project Configuration  
   |    |-- urls.py                      # Project Routing
   |
   |-- home/
   |    |-- views.py                     # APP Views 
   |    |-- urls.py                      # APP Routing
   |    |-- models.py                    # APP Models 
   |    |-- tests.py                     # Tests  
   |    |-- templates/                   # Theme Customisation 
   |         |-- includes                # 
   |              |-- footer.py          # Custom Footer      
   |     
   |-- requirements.txt                  # Project Dependencies
   |
   |-- env.sample                        # ENV Configuration (default values)
   |-- manage.py                         # Start the app - Django default start script
   |
   |-- ************************************************************************


Django Dynamic Services - Open-Source Django starter provided by AppSeed