Skip to main content

...

Project description

Django Utilitybox

Logo

Managment software by 'On road Rescues': Stable Version.

Installation

  pip install django-utilitybox

Usage

Raise Exception

  from django_utilitybox.response import raise_response as rres

This utility makes it easier to return errors in DRF. Giving a default message and a status. The options are as follows.

Class Status Message Use cases
QueryParamNotFound 400 Queryparam '{field}' is required Used when a query param is not found in the url
KwargNotFound 400 Kwarg '{field}' is required Used when a kwarg is not found
ModelNotFound 400 {field} don't exist Used when a model is not found
CustomRaise 400 Se usa cuando se quiere mandar un mensaje personalizado

Use cases

	 class  ResponseTest(APIView):
		def  get(self, *args, **kwargs):
		data:dict  =  self.request.GET
		param  =  data.get('case')
		match  param:
			case  '1': rres.QueryParamNotFound('id')
			case  '2': rres.KwargNotFound ('data')
			case  '3': rres.ModelNotFound('Rescue')
			case  '4': rres.CustomRaise('Custom message')
		return  Response({'message': 'Successful.'}, status=st.HTTP_200_OK)

Returns

Class Status Message
QueryParamNotFound 400 Queryparam 'id' is required
KwargNotFound 400 Kwarg 'data' is required
ModelNotFound 400 Rescue don't exist
CustomRaise 400 Custom message

Json returned

HTTP 400 Bad Request
{
	"status":  "{message}"
}

Modifiable parameters

WIP


Used By

This project is used by the following companies:

  • AETO Software

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_utilitybox-0.1.3.tar.gz (10.6 kB view details)

Uploaded Source

File details

Details for the file django_utilitybox-0.1.3.tar.gz.

File metadata

  • Download URL: django_utilitybox-0.1.3.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for django_utilitybox-0.1.3.tar.gz
Algorithm Hash digest
SHA256 10cba2aadc5210a623d36c4e768c52c00a19a277a72bffa26b24dc3d8ea7013a
MD5 c9e4bcc79f344317b7a5915923ce4c16
BLAKE2b-256 2a91b4d517480bf0c9d26c268fb755908936cd8d837cc8024d17c7b66db388c7

See more details on using hashes here.

Supported by

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