CRUD Operations¶
Rapid Development
Unchained provides automatic CRUD (Create, Read, Update, Delete) operations through the app.crud()
method, enabling you to build REST APIs with minimal code.
Basic Usage¶
With just a single line of code, you can generate complete CRUD endpoints for your models:
from unchained import Unchained
from unchained.models.base import BaseModel
from django.db import models
class User(BaseModel):
name = models.CharField(max_length=255)
email = models.EmailField(unique=True)
app = Unchained()
app.crud(User) # Generates all CRUD endpoints for User model
Generated Endpoints
The app.crud(User)
method generates the following endpoints:
GET /api/users
- List all usersGET /api/users/{id}
- Get a specific user by IDPOST /api/users
- Create a new userPUT /api/users/{id}
- Update a userDELETE /api/users/{id}
- Delete a user
Example Usage¶
Further Reading¶
For more information on the underlying technologies: