Skip to main content

Advanced Intelligent Django API CRUD Framework

Project description

AIDA-CRUD

Advanced Intelligent Django API CRUD Framework

A comprehensive, DRY solution for building feature-rich CRUD operations in Django REST Framework applications.

Installation

pip install aida-crud

Quick Start

1. Add to Django Settings

INSTALLED_APPS = [
    # ...
    'rest_framework',
    'django_filters',
    'aida_crud',
]

2. Create Your Models

from aida_crud.core import SoftDeleteModel

class Product(SoftDeleteModel):
    name = models.CharField(max_length=200)
    price = models.DecimalField(max_digits=10, decimal_places=2)
    
    class Meta:
        ordering = ['-created_at']

3. Create Serializers

from aida_crud.serializers import AidaModelSerializer

class ProductSerializer(AidaModelSerializer):
    class Meta:
        model = Product
        fields = '__all__'

4. Create ViewSets

from aida_crud.viewsets import AidaModelViewSet

class ProductViewSet(AidaModelViewSet):
    queryset = Product.objects.all()
    serializer_class = ProductSerializer
    search_fields = ['name', 'description']
    ordering_fields = '__all__'

Features

Backend Capabilities

  • Generic ViewSets - Automatic CRUD operations with minimal code
  • Dynamic Serializers - Context-aware field selection and expansion
  • Advanced Filtering - Built-in search, ordering, and filtering
  • Bulk Operations - Create, update, and delete multiple records
  • Soft Delete - Safe deletion with restore capabilities
  • Audit Trail - Comprehensive activity logging
  • Data Export - CSV, JSON, and Excel export support
  • API Metadata - Auto-configuration endpoints for frontends

Built-in Endpoints

Each ViewSet automatically provides:

  • GET /api/resource/ - List with pagination
  • POST /api/resource/ - Create new item
  • GET /api/resource/{id}/ - Retrieve item
  • PUT/PATCH /api/resource/{id}/ - Update item
  • DELETE /api/resource/{id}/ - Soft delete item
  • POST /api/resource/bulk-create/ - Bulk create
  • POST /api/resource/bulk-update/ - Bulk update
  • POST /api/resource/bulk-delete/ - Bulk delete
  • GET /api/resource/export/ - Export data
  • OPTIONS /api/resource/metadata/ - Get metadata

Advanced Usage

Custom Filters

from aida_crud.filters import AidaFilterSet

class ProductFilterSet(AidaFilterSet):
    min_price = django_filters.NumberFilter(field_name='price', lookup_expr='gte')
    max_price = django_filters.NumberFilter(field_name='price', lookup_expr='lte')
    
    class Meta:
        model = Product
        fields = ['name', 'category', 'is_active']

Audit Logging

from aida_crud.audit import AuditLog

# Automatic logging in ViewSets
class ProductViewSet(AidaModelViewSet):
    # All CRUD operations are automatically logged
    pass

# Manual logging
AuditLog.log_action(
    user=request.user,
    action='CUSTOM_ACTION',
    obj=product,
    changes={'price': {'old': 100, 'new': 150}}
)

Bulk Operations

# In your ViewSet
class ProductViewSet(AidaModelViewSet):
    bulk_actions = ['archive', 'activate', 'deactivate']
    
    def bulk_archive(self, queryset, **kwargs):
        count = queryset.update(is_archived=True)
        return {'archived': count}

Configuration

ViewSet Options

class MyViewSet(AidaModelViewSet):
    # Display configuration
    list_display = ['name', 'price', 'created_at']
    list_filter = ['category', 'is_active']
    search_fields = ['name', 'description']
    ordering_fields = '__all__'
    ordering = ['-created_at']
    
    # Bulk operations
    bulk_actions = ['delete', 'archive', 'activate']
    
    # Export configuration
    export_formats = ['csv', 'json', 'xlsx']
    export_fields = ['name', 'price', 'category']
    
    # Computed fields
    computed_fields = {
        'display_price': lambda obj: f'${obj.price:.2f}'
    }

Requirements

  • Python 3.8+
  • Django 3.2+
  • Django REST Framework 3.12+
  • django-filter 2.4+

License

MIT License - see LICENSE file for details.

Contributing

Contributions are welcome! Please visit our GitHub repository.

Support

For issues and questions, please use our GitHub Issues.

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

aida_crud-1.0.1.tar.gz (19.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aida_crud-1.0.1-py3-none-any.whl (21.4 kB view details)

Uploaded Python 3

File details

Details for the file aida_crud-1.0.1.tar.gz.

File metadata

  • Download URL: aida_crud-1.0.1.tar.gz
  • Upload date:
  • Size: 19.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.3

File hashes

Hashes for aida_crud-1.0.1.tar.gz
Algorithm Hash digest
SHA256 24e2c64ea3bc1c9b317de5e4b27a906baa7a2a2b47f3e02247971428c295db7d
MD5 02dae456bd6d3a3328074639f8d0a241
BLAKE2b-256 bb99f76bc7c2946cef6ead47e45a167e61fc01af5dadc12909583a4762e24d58

See more details on using hashes here.

File details

Details for the file aida_crud-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: aida_crud-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 21.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.3

File hashes

Hashes for aida_crud-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 21d20f01b3cfec18dd83faa39027842dcaad4ac0c15551610b2201ecf3a7456c
MD5 6e3b68d5b9cb3ec8b4df512eb183461f
BLAKE2b-256 d4753ef82bad9fd4ae63911fbc880482d1f129bf0024c52d53dd55ff932413d0

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