Rapid develop framework base on Django
Project description
Django Rework
Rapid develop framework base on Django, integrated with Django-Ninja.
Installation & Cli commands
Requirements
- Python >= 3.8
- Django >= 3.2
- Django REST framework >=3.13,<4.0
Install django-rework
pip install django-rework
Generic CLI Commands
Start a new project
# It will create project in current dir
# eg: initialize a new project named `pony`
rework init pony
Add build-in contrib Apps
rework add users
Add deployment configurations
rework deploy --init
Deploy to test or production
rework deploy # or 'fab -H web1 deploy'
Core docs
Custom exceptions
The exception handler must also be configured in your settings, using the EXCEPTION_HANDLER setting key. For example:
REST_FRAMEWORK = {
'EXCEPTION_HANDLER': 'rework.core.views.exception_handler'
}
Use build-in custom exceptions:
from rework.core.exceptions import ValidateError
ValidateError(
detail='You do not have permission to perform this action.',
code='permission_denied',
)
App docs
App | Description | docs in English | 简体中文文档 |
---|---|---|---|
users | Users system | users.md | users_cn.md |
DevOps Fabric scripts
Setup hosts
django-rework
deal with DevOps using Fabric
. You should add hosts configurations in fabfile.py
.
import os
from rework.core.devops.hosts import loads
# The first argument `default` is host alias
# `user` is optional, default value is `root`
# `envs` is the server support deploy environments
# `exclude_components` is optional, it's been used in `fab setup_server`
loads(
'default', {
'host': 'your-server-ip',
'port': 22,
'user': 'root',
'connect_kwargs': {
'password': 'server-password',
},
'envs': ['test', 'prod'],
'exclude_components': ['redis'],
}
)
# Using SSH key
loads(
'web1', {
'host': 'your-server-ip',
'connect_kwargs': {
'key_filename': os.path.join(os.path.abspath('.'), '.deploy/private.pem'),
},
}
)
You can change host alias as you like: web1
etc.
fab -H web1 deploy
if not -H
provided, the default alias will use according the order below:
- environment name:
dev
,test
,prod
default
Deploy environments
By default, environments is dev
, test
, prod
, every environment name is a generic fabric tasks.
# deploy to `test` environment
fab test deploy
If you want to update requirements, you should add arguments -r
or --requirements_update
fab test deploy -r
Code Format
Code format using Google 的 yapf
,recommend to install yapf
globally:
# install yapf using pip in python3
$ python3 -m pip install yapf
# find and create soft link to `/usr/local/bin/yapf`
# find yapf execute file
$ which yapf
# (/usr/local/python3.7/bin/yapf) possible location
$ ln -s /usr/local/python3.7/bin/yapf /usr/local/bin/yapf
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django_rework-0.5.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57e23100fc86cbd58aa042ca8788dd602c31da90d7f6fe7250596f6c2970720b |
|
MD5 | bb05fc849e76a45091c177a959c5b0d3 |
|
BLAKE2b-256 | f526a04721002ba50169330a646103eee1a7ed2b3906601e156b8bccbe2d9858 |