Quick Start Guide¶
This guide will help you get started with DRF Toolkit quickly. We'll cover installation, basic setup, and common use cases.
Installation¶
pip install drf-toolkit
Basic Setup¶
- Add
drf_kit
to yourINSTALLED_APPS
:
INSTALLED_APPS = [
...
'drf_kit',
]
- Configure your Django REST Framework settings (if not already done):
REST_FRAMEWORK = {
'DEFAULT_PAGINATION_CLASS': 'drf_kit.pagination.PageNumberPagination',
'PAGE_SIZE': 100,
}
Common Use Cases¶
1. Enhanced Models¶
Use our enhanced model classes for common functionality:
from drf_kit.models import BaseModel
class User(BaseModel):
name = models.CharField(max_length=100)
email = models.EmailField(unique=True)
2. Advanced Filtering¶
Implement powerful filtering in your views:
from drf_kit.filters import FilterSet
class UserFilter(FilterSet):
class Meta:
model = User
fields = ['name', 'email']
class UserViewSet(viewsets.ModelViewSet):
queryset = User.objects.all()
filterset_class = UserFilter
3. Soft Delete¶
Add soft delete capability to your models:
from drf_kit.models import SoftDeleteModel
class Document(SoftDeleteModel):
title = models.CharField(max_length=100)
content = models.TextField()
4. Enhanced Serializers¶
Use our enhanced serializers for better validation and flexibility:
from drf_kit.serializers import ModelSerializer
class UserSerializer(ModelSerializer):
class Meta:
model = User
fields = ['id', 'name', 'email']
Next Steps¶
- Check out the Models documentation for more model features
- Learn about Serializers for advanced serialization
- Explore Views for enhanced viewset capabilities
- See Filters for advanced filtering options
- Review Testing for testing utilities
For more detailed information about specific features, check the respective documentation sections.