Skip to main content

No project description provided

Project description

Build Status pypi python license Development status

Instalation

pip install django-api-toolkit

Get started

In the first you need initialize your project

project_init <path to project>

For existing projects you should to generate env file

env_generator <path to project>

This script generate base variables that needed to run project. You can also add youself variables in env file You should also change your manage.py. Add APIManager to your file. e.q.

#!/usr/bin/env python
import sys

from api_tools.utils import APIManager

if __name__ == "__main__":
    er = APIManager(__file__, 'cfg.settings')  # path to user project settings
    er.set_app_dir('apps')  # directory for user project applications
    er.apply()  # apply settings

    from django.core.management import execute_from_command_line
    execute_from_command_line(sys.argv)

Usage

Structure

├── apps  # dir for your apps
├── cfg  # dir for diferent project configurations
   ├── settings.py # user project settings
   └── wsgi.py
└── manage.py

Settings

  • COMMON_APPS - django common applications

  • THIRD_PARTY_APPS - third party applications

  • EXTRA_APPS - applications should be insted before common apps

  • PROJECT_APPS - your project applications

You also can overwrite other standard django settings keys and add yourself variables

Models

All project models should be inherited of RestModel(this standart django abstract model and you can use all capabilities of this)

from api_tools.models import RestModel

class MyModel(RestModel):
    ...

Advanced

RestModel have subclass Rest. This subclass have properties for control your rest models. RestModel also have classmethods for these controls.

RestModel overwrites

RestModel.Rest

queryset:

defines queryset as lambda of model.objects

fields:

list of allowed fields of model

name:

name of viewset

route:

route of endpoint

RestModel._rest_serializer

Defines serializer for viewset of model

RestModel._rest_queryset

Defines queryset for viewset

RestModel._rest_endpoint

Set endpoint for your model

FEATURES

CHANGELOG

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-api-toolkit-0.1.3.tar.gz (7.7 kB view details)

Uploaded Source

File details

Details for the file django-api-toolkit-0.1.3.tar.gz.

File metadata

File hashes

Hashes for django-api-toolkit-0.1.3.tar.gz
Algorithm Hash digest
SHA256 ca2fbab1c370642a1c66f85f49b40361224208b4c66857d5cf1ca54365b095fd
MD5 9a8a3cf249007c27883c008bd718ce79
BLAKE2b-256 62a76f4d627e9c359af6b9b4bd45a23c66fc7443033cb9c37cce56ed3fa6fa56

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page