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.0.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.0-py3-none-any.whl (21.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: aida_crud-1.0.0.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.0.tar.gz
Algorithm Hash digest
SHA256 bd2c2d715b868e437b0d5dfe9393f690820b61f45554a50eecaf38849e8865ac
MD5 10be6a844d395a32bbdb7590d7df1480
BLAKE2b-256 92925cd99d0ccdfeb1f7711e894d2d316e05f5818013e741b6fbfdda03a76020

See more details on using hashes here.

File details

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

File metadata

  • Download URL: aida_crud-1.0.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d42aa9579e4a4394f5e77652d70ac152ac250ea422c645db67ff63354d013903
MD5 921d7b812b85907aba7464c5c59d826c
BLAKE2b-256 d24ebc3c844a39154e9ecf6d3b26019ca500e6c05ff5c6617e13783296fc3bfb

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