django-cruder


Namedjango-cruder JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/django-cruder/django-cruder
SummaryAdvanced CRUD operations for Django with multiple CSS framework support
upload_time2025-07-19 11:24:44
maintainerNone
docs_urlNone
authorDjango Cruder Team
requires_python>=3.8
licenseNone
keywords django crud forms bootstrap bulma css framework
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Django Cruder

Advanced CRUD operations for Django with multiple CSS framework support and powerful features.

[![Documentation Status](https://readthedocs.org/projects/django-cruder/badge/?version=latest)](https://django-cruder.readthedocs.io/en/latest/?badge=latest)
[![PyPI version](https://badge.fury.io/py/django-cruder.svg)](https://badge.fury.io/py/django-cruder)

## 🚀 Quick Start

### Installation

```bash
pip install django-cruder
```

Add to your `INSTALLED_APPS`:

```python
INSTALLED_APPS = [
    # ... your other apps
    'cruder',
]
```

### 1. Create Your Model

```python
# 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
```

### 2. Create Your View (One Line!)

```python
# 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)
```

### 3. Add URLs (One Line!)

```python
# 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:
- ✅ List view with multi-field search and pagination
- ✅ Create form with validation
- ✅ View details
- ✅ Edit form with read-only fields
- ✅ Delete confirmation
- ✅ Bootstrap 5 styling
- ✅ Permission-based access control

## 🌟 Features

### Core Features
- **One-line CRUD**: Complete CRUD operations with minimal code
- **Multi-framework support**: Bootstrap 5, Bulma, and extensible for more
- **Auto-generated forms**: Dynamic form generation from Django models
- **Smart list views**: Automatic table generation with pagination and search
- **Template integration**: Works seamlessly with your existing Django templates

### Advanced Features
- **Multi-field search**: OR search across multiple model fields
- **Read-only modes**: Full read-only or field-level read-only controls
- **Permission system**: Role-based access control for CRUD operations
- **Framework flexibility**: Easy switching between CSS frameworks
- **Custom templates**: Override any template for full customization

## 📚 Documentation

Full documentation is available at [django-cruder.readthedocs.io](https://django-cruder.readthedocs.io/)

## 🔧 API Reference

### `crud_view(model_class, framework='bootstrap', **kwargs)`

**Core Parameters:**
- `model_class`: Django model class
- `framework`: CSS framework ('bootstrap' or 'bulma')

**Display Parameters:**
- `exclude_fields`: List of fields to exclude from forms
- `list_fields`: Fields to show in list view (defaults to all non-excluded)
- `readonly_fields`: Fields that should be read-only in forms

**Search & 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-only
- `permissions`: Dict mapping CRUD operations to required roles
- `permission_required`: Django permission required for access

### URL Helper

```python
crud_urlpatterns(url_prefix, view_func, name_prefix=None)
```

Automatically generates all 5 CRUD URL patterns:
- List: `/{url_prefix}/`
- Create: `/{url_prefix}/create/`
- View: `/{url_prefix}/<int:pk>/`
- Edit: `/{url_prefix}/<int:pk>/edit/`
- Delete: `/{url_prefix}/<int:pk>/delete/`

## 🎨 Framework Support

### Bootstrap 5 (Default)
```python
crud_view(MyModel, framework='bootstrap')
```

### Bulma
```python
crud_view(MyModel, framework='bulma')
```

### Custom Frameworks
Easily add support for any CSS framework by extending `BaseFramework`.

## 🔒 Security Features

### Role-Based Permissions
```python
crud_view(
    MyModel,
    permissions={
        'C': ['admin', 'editor'],  # Create: admin or editor
        'R': [],                   # Read: everyone
        'U': ['admin'],           # Update: admin only
        'D': ['admin']            # Delete: admin only
    }
)
```

### Django Permissions
```python
@permission_required('myapp.change_mymodel')
def my_crud_view(request, pk=None, action='list'):
    return crud_view(MyModel)(request, pk, action)
```

## 🔍 Advanced Search

Multi-field search with OR logic:
```python
crud_view(
    Contact,
    search_fields=['name', 'email', 'phone', 'company']
)
```

## 📝 Field Type Support

Django Cruder automatically handles all Django field types:

- **Text Fields**: CharField, TextField, EmailField, URLField
- **Numeric Fields**: IntegerField, FloatField, DecimalField
- **Date/Time Fields**: DateField, DateTimeField, TimeField
- **Boolean Fields**: BooleanField with Yes/No dropdown
- **Choice Fields**: Automatic dropdown generation
- **Foreign Keys**: Basic support with proper display
- **File Fields**: FileField and ImageField support

## 🛠️ Requirements

- Python 3.8+
- Django 3.2+

## 📄 License

MIT License - see LICENSE file for details.

## 🤝 Contributing

Contributions are welcome! Please read our contributing guidelines and submit pull requests to our GitHub repository.

## 📞 Support

- Documentation: [django-cruder.readthedocs.io](https://django-cruder.readthedocs.io/)
- Issues: [GitHub Issues](https://github.com/massyn/django-cruder/issues)
- Discussions: [GitHub Discussions](https://github.com/massyn/django-cruder/discussions)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/django-cruder/django-cruder",
    "name": "django-cruder",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "Phil Massyn <phil.massyn@icloud.com>",
    "keywords": "django, crud, forms, bootstrap, bulma, css, framework",
    "author": "Django Cruder Team",
    "author_email": "Phil Massyn <phil.massyn@icloud.com>",
    "download_url": "https://files.pythonhosted.org/packages/07/d5/664ed5372e026ddbba030f992af2d1ecaa53094e02628bdcc2578416aa0b/django_cruder-1.0.0.tar.gz",
    "platform": null,
    "description": "# Django Cruder\n\nAdvanced CRUD operations for Django with multiple CSS framework support and powerful features.\n\n[![Documentation Status](https://readthedocs.org/projects/django-cruder/badge/?version=latest)](https://django-cruder.readthedocs.io/en/latest/?badge=latest)\n[![PyPI version](https://badge.fury.io/py/django-cruder.svg)](https://badge.fury.io/py/django-cruder)\n\n## \ud83d\ude80 Quick Start\n\n### Installation\n\n```bash\npip install django-cruder\n```\n\nAdd to your `INSTALLED_APPS`:\n\n```python\nINSTALLED_APPS = [\n    # ... your other apps\n    'cruder',\n]\n```\n\n### 1. Create Your Model\n\n```python\n# models.py\nfrom django.db import models\n\nclass Contact(models.Model):\n    name = models.CharField(max_length=100, verbose_name=\"Full Name\")\n    email_address = models.EmailField(verbose_name=\"Email\")\n    phone_number = models.CharField(max_length=20, verbose_name=\"Phone\")\n    active_client = models.BooleanField(default=True, verbose_name=\"Active\")\n    notes = models.TextField(blank=True)\n    created_at = models.DateTimeField(auto_now_add=True)\n    updated_at = models.DateTimeField(auto_now=True)\n    \n    def __str__(self):\n        return self.name\n```\n\n### 2. Create Your View (One Line!)\n\n```python\n# views.py\nfrom django.contrib.auth.decorators import login_required\nfrom cruder import crud_view\nfrom .models import Contact\n\n@login_required\ndef contact_crud(request, pk=None, action='list'):\n    return crud_view(\n        Contact,\n        framework='bootstrap',\n        exclude_fields=['created_at', 'updated_at'],\n        list_fields=['name', 'email_address', 'phone_number', 'active_client'],\n        readonly_fields=['name'],\n        per_page=10,\n        search_fields=['name', 'email_address', 'phone_number']\n    )(request, pk, action)\n```\n\n### 3. Add URLs (One Line!)\n\n```python\n# urls.py\nfrom cruder.urls import crud_urlpatterns\nfrom . import views\n\nurlpatterns = [\n    # ... your other URLs\n] + crud_urlpatterns('contacts', views.contact_crud)\n```\n\n**That's it!** You now have a complete CRUD interface with:\n- \u2705 List view with multi-field search and pagination\n- \u2705 Create form with validation\n- \u2705 View details\n- \u2705 Edit form with read-only fields\n- \u2705 Delete confirmation\n- \u2705 Bootstrap 5 styling\n- \u2705 Permission-based access control\n\n## \ud83c\udf1f Features\n\n### Core Features\n- **One-line CRUD**: Complete CRUD operations with minimal code\n- **Multi-framework support**: Bootstrap 5, Bulma, and extensible for more\n- **Auto-generated forms**: Dynamic form generation from Django models\n- **Smart list views**: Automatic table generation with pagination and search\n- **Template integration**: Works seamlessly with your existing Django templates\n\n### Advanced Features\n- **Multi-field search**: OR search across multiple model fields\n- **Read-only modes**: Full read-only or field-level read-only controls\n- **Permission system**: Role-based access control for CRUD operations\n- **Framework flexibility**: Easy switching between CSS frameworks\n- **Custom templates**: Override any template for full customization\n\n## \ud83d\udcda Documentation\n\nFull documentation is available at [django-cruder.readthedocs.io](https://django-cruder.readthedocs.io/)\n\n## \ud83d\udd27 API Reference\n\n### `crud_view(model_class, framework='bootstrap', **kwargs)`\n\n**Core Parameters:**\n- `model_class`: Django model class\n- `framework`: CSS framework ('bootstrap' or 'bulma')\n\n**Display Parameters:**\n- `exclude_fields`: List of fields to exclude from forms\n- `list_fields`: Fields to show in list view (defaults to all non-excluded)\n- `readonly_fields`: Fields that should be read-only in forms\n\n**Search & Pagination:**\n- `search_fields`: List of fields to enable search across (OR logic)\n- `per_page`: Items per page for pagination (default: 25)\n\n**Advanced Features:**\n- `readonly_mode`: Make entire interface read-only\n- `permissions`: Dict mapping CRUD operations to required roles\n- `permission_required`: Django permission required for access\n\n### URL Helper\n\n```python\ncrud_urlpatterns(url_prefix, view_func, name_prefix=None)\n```\n\nAutomatically generates all 5 CRUD URL patterns:\n- List: `/{url_prefix}/`\n- Create: `/{url_prefix}/create/`\n- View: `/{url_prefix}/<int:pk>/`\n- Edit: `/{url_prefix}/<int:pk>/edit/`\n- Delete: `/{url_prefix}/<int:pk>/delete/`\n\n## \ud83c\udfa8 Framework Support\n\n### Bootstrap 5 (Default)\n```python\ncrud_view(MyModel, framework='bootstrap')\n```\n\n### Bulma\n```python\ncrud_view(MyModel, framework='bulma')\n```\n\n### Custom Frameworks\nEasily add support for any CSS framework by extending `BaseFramework`.\n\n## \ud83d\udd12 Security Features\n\n### Role-Based Permissions\n```python\ncrud_view(\n    MyModel,\n    permissions={\n        'C': ['admin', 'editor'],  # Create: admin or editor\n        'R': [],                   # Read: everyone\n        'U': ['admin'],           # Update: admin only\n        'D': ['admin']            # Delete: admin only\n    }\n)\n```\n\n### Django Permissions\n```python\n@permission_required('myapp.change_mymodel')\ndef my_crud_view(request, pk=None, action='list'):\n    return crud_view(MyModel)(request, pk, action)\n```\n\n## \ud83d\udd0d Advanced Search\n\nMulti-field search with OR logic:\n```python\ncrud_view(\n    Contact,\n    search_fields=['name', 'email', 'phone', 'company']\n)\n```\n\n## \ud83d\udcdd Field Type Support\n\nDjango Cruder automatically handles all Django field types:\n\n- **Text Fields**: CharField, TextField, EmailField, URLField\n- **Numeric Fields**: IntegerField, FloatField, DecimalField\n- **Date/Time Fields**: DateField, DateTimeField, TimeField\n- **Boolean Fields**: BooleanField with Yes/No dropdown\n- **Choice Fields**: Automatic dropdown generation\n- **Foreign Keys**: Basic support with proper display\n- **File Fields**: FileField and ImageField support\n\n## \ud83d\udee0\ufe0f Requirements\n\n- Python 3.8+\n- Django 3.2+\n\n## \ud83d\udcc4 License\n\nMIT License - see LICENSE file for details.\n\n## \ud83e\udd1d Contributing\n\nContributions are welcome! Please read our contributing guidelines and submit pull requests to our GitHub repository.\n\n## \ud83d\udcde Support\n\n- Documentation: [django-cruder.readthedocs.io](https://django-cruder.readthedocs.io/)\n- Issues: [GitHub Issues](https://github.com/massyn/django-cruder/issues)\n- Discussions: [GitHub Discussions](https://github.com/massyn/django-cruder/discussions)\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Advanced CRUD operations for Django with multiple CSS framework support",
    "version": "1.0.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/massyn/django-cruder/issues",
        "Documentation": "https://django-cruder.readthedocs.io/",
        "Homepage": "https://github.com/massyn/django-cruder",
        "Repository": "https://github.com/massyn/django-cruder"
    },
    "split_keywords": [
        "django",
        " crud",
        " forms",
        " bootstrap",
        " bulma",
        " css",
        " framework"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "7a4df5d3028e3806320d0e8528ab80615d13c6f85a3a9b4d5155f980f793ad5c",
                "md5": "ed5072ddb4384b18fd0c0505c68ad17c",
                "sha256": "8c90f55d828612079cccbb5428780fb8ba4f37ac70903f3c17b09371d5768250"
            },
            "downloads": -1,
            "filename": "django_cruder-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ed5072ddb4384b18fd0c0505c68ad17c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 22187,
            "upload_time": "2025-07-19T11:24:43",
            "upload_time_iso_8601": "2025-07-19T11:24:43.313425Z",
            "url": "https://files.pythonhosted.org/packages/7a/4d/f5d3028e3806320d0e8528ab80615d13c6f85a3a9b4d5155f980f793ad5c/django_cruder-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "07d5664ed5372e026ddbba030f992af2d1ecaa53094e02628bdcc2578416aa0b",
                "md5": "bc629c0d427cef781abdf3eb2199058b",
                "sha256": "91ebd229d08ce04fce817736e52d29ba489cac59ef935f4b1da94c2475bb934b"
            },
            "downloads": -1,
            "filename": "django_cruder-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "bc629c0d427cef781abdf3eb2199058b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 20615,
            "upload_time": "2025-07-19T11:24:44",
            "upload_time_iso_8601": "2025-07-19T11:24:44.469696Z",
            "url": "https://files.pythonhosted.org/packages/07/d5/664ed5372e026ddbba030f992af2d1ecaa53094e02628bdcc2578416aa0b/django_cruder-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-19 11:24:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "django-cruder",
    "github_project": "django-cruder",
    "github_not_found": true,
    "lcname": "django-cruder"
}
        
Elapsed time: 1.92016s