app like that
Djapy
Djapy

Djapy is a Python framework for creating RESTful APIs within Django without boilerplate code, using Python and Pydantic. It offers zero boilerplate, type safety with Pydantic validation, async support, and modern authentication. Features include smart validation, auto documentation with OpenAPI/Swagger, Django-native integration, flexible pagination, customizable error handling, and IDE support. It requires Python 3.10+ and is installable via PyPI.

Features

Zero Boilerplate

Build APIs with pure Python without the need for serializers, viewsets, or extra configuration.

Type Safety

Provides full Python type hints with Pydantic validation to ensure data integrity and type checking.

Async Support

Allows writing high-performance async views using the '@async_djapyfy' decorator for better concurrency.

Modern Auth

Offers simple session authentication with customizable mechanisms to enhance security.

Smart Validation

Includes built-in request/response validation using Pydantic for robust data validation.

Auto Documentation

Integrates with OpenAPI/Swagger for automatic documentation generation, including dark mode support.

Django Native

Seamlessly works with Django's decorators and features, ensuring compatibility and ease of use.

Flexible Pagination

Supports built-in cursor, offset-limit, and page number pagination for efficient data retrieval.

Error Handling

Customizable error handling and validation messages to better manage exceptions.

IDE Friendly

Provides full IntelliSense and type checking support to improve development efficiency.

Async and Sync Decorators

Allows you to define views as either synchronous with `@djaqify` or asynchronous with `@async_djaqify`, providing flexibility in API design.

Function Signature

The first argument is always the request object. Additional arguments are extracted from the request. Return type annotations have a specific format `{status_code: SchemaType}` to define response types.

Return Values

Supports single and tuple return values, allowing you to define different responses including status code and message content.

Schema Mapping

Automatically validates and serializes return values according to predefined Django schemas. Use models and dictionaries validated against schemas, ensuring strong type checks.

Async Support

Supports asynchronous operations using `@async_djaqify`, which allows you to await async ORM operations. Provides guidance on converting sync to async queries.

JSON Data Handling

Handles JSON data (application/json) by structuring and validating it using schemas, ensuring robust data input handling.

Form Data Handling

Processes form data (application/x-www-form-urlencoded) for easy parsing and validation, especially useful for web form submissions.

Query Parameter Handling

Enables easy extraction and management of query parameters from URLs, useful for dynamic URL-driven applications.

Type Validation

Utilizes Pydantic models for strong type checking in data validation, providing clear feedback on invalid data inputs.

Invalid Data Response

Generates clear and informative error messages when data validation fails, assisting in debugging and correcting input errors.

Advanced Features - Basic Types as JSON Input

Allows basic types to be used in JSON bodies with Pydantic, enabling simplicity in input processing.

String Constraints

Implements Pydantic's powerful string validation constraints for high data integrity and error-proof input processing.

Automatic Response Serialization

Automatically serializes responses to JSON using the Pydantic model. If the response is valid according to the model, it returns with a 200 status code.

Pydantic Validators

Allows the use of Pydantic's field validator decorator to ensure that the fields of a schema adhere to specified rules.

Computed Fields

Allows the definition of computed fields using the @computed_field decorator in a schema, creating fields that are computed from existing model fields.

Accessing Context in Computed Fields

Provides access to context in the computed field using the context parameter, enabling dynamic computation based on request context.

Accessing Source Object in Computed Field

Accesses the source object in the computed field using the _obj attribute, useful for getting related information from Django model instances.

Return Schema for Multiple Status Codes

Enables the configuration of response schema for multiple status codes using the uni_schema function.

QuerySet and List Return Types

Facilitates returning many-to-many relationships or Django querysets using the QueryList type.

Image Field Handling

Utilizes ImageField type to manage image fields efficiently within schemas.

Async and Sync View Compatibility

Supports both async and sync views with similar structure for consistent API handling.