
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Advanced CRUD operations for Django with multiple CSS framework support and powerful features.
pip install django-cruder
Add to your INSTALLED_APPS
:
INSTALLED_APPS = [
# ... your other apps
'cruder',
]
# models.py
from django.db import models
class Contact(models.Model):
name = models.CharField(max_length=100, verbose_name="Full Name")
email_address = models.EmailField(verbose_name="Email")
phone_number = models.CharField(max_length=20, verbose_name="Phone")
active_client = models.BooleanField(default=True, verbose_name="Active")
notes = models.TextField(blank=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
def __str__(self):
return self.name
# views.py
from django.contrib.auth.decorators import login_required
from cruder import crud_view
from .models import Contact
@login_required
def contact_crud(request, pk=None, action='list'):
return crud_view(
Contact,
framework='bootstrap',
exclude_fields=['created_at', 'updated_at'],
list_fields=['name', 'email_address', 'phone_number', 'active_client'],
readonly_fields=['name'],
per_page=10,
search_fields=['name', 'email_address', 'phone_number']
)(request, pk, action)
# urls.py
from cruder.urls import crud_urlpatterns
from . import views
urlpatterns = [
# ... your other URLs
] + crud_urlpatterns('contacts', views.contact_crud)
That's it! You now have a complete CRUD interface with:
Full documentation is available at django-cruder.readthedocs.io
crud_view(model_class, framework='bootstrap', **kwargs)
Core Parameters:
model_class
: Django model classframework
: CSS framework ('bootstrap' or 'bulma')Display Parameters:
exclude_fields
: List of fields to exclude from formslist_fields
: Fields to show in list view (defaults to all non-excluded)readonly_fields
: Fields that should be read-only in formsSearch & Pagination:
search_fields
: List of fields to enable search across (OR logic)per_page
: Items per page for pagination (default: 25)Advanced Features:
readonly_mode
: Make entire interface read-onlypermissions
: Dict mapping CRUD operations to required rolespermission_required
: Django permission required for accesscrud_urlpatterns(url_prefix, view_func, name_prefix=None)
Automatically generates all 5 CRUD URL patterns:
/{url_prefix}/
/{url_prefix}/create/
/{url_prefix}/<int:pk>/
/{url_prefix}/<int:pk>/edit/
/{url_prefix}/<int:pk>/delete/
crud_view(MyModel, framework='bootstrap')
crud_view(MyModel, framework='bulma')
Easily add support for any CSS framework by extending BaseFramework
.
crud_view(
MyModel,
permissions={
'C': ['admin', 'editor'], # Create: admin or editor
'R': [], # Read: everyone
'U': ['admin'], # Update: admin only
'D': ['admin'] # Delete: admin only
}
)
@permission_required('myapp.change_mymodel')
def my_crud_view(request, pk=None, action='list'):
return crud_view(MyModel)(request, pk, action)
Multi-field search with OR logic:
crud_view(
Contact,
search_fields=['name', 'email', 'phone', 'company']
)
Django Cruder automatically handles all Django field types:
MIT License - see LICENSE file for details.
Contributions are welcome! Please read our contributing guidelines and submit pull requests to our GitHub repository.
FAQs
Advanced CRUD operations for Django with multiple CSS framework support
We found that django-cruder demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.