Django REST Framework
Category: backend October 19, 2025
Agent instructions for Django REST Framework API development
pythondjangorestapi
# Django REST Framework Development
## Setup
- Create virtualenv: `python -m venv venv`
- Activate: `source venv/bin/activate`
- Install: `pip install -r requirements.txt`
- Migrations: `python manage.py migrate`
- Run server: `python manage.py runserver`
- Tests: `python manage.py test`
## Project Structure
project/ ├── manage.py ├── project/ # Settings & config ├── apps/ # Django apps │ └── api/ │ ├── models.py │ ├── serializers.py │ ├── views.py │ └── urls.py └── tests/
## Best Practices
- Use ModelSerializer for CRUD operations
- Implement ViewSets for standard REST endpoints
- Use Django ORM querysets efficiently
- Apply DRY principle with serializers
- Implement proper permission classes
## Testing
- Write tests for all API endpoints
- Use APIClient for integration tests
- Test authentication and permissions
- Maintain > 80% coverage