Skip to main content

django-cruds

https://travis-ci.org/bmihelac/django-cruds.png?branch=master https://coveralls.io/repos/bmihelac/django-cruds/badge.png?branch=master https://img.shields.io/pypi/v/django-cruds.svg

django-cruds is simple drop-in django app that creates CRUD (Create, read, update and delete) views for existing models and apps.

django-cruds goal is to make prototyping faster.

Documentation

To add CRUD for whole app, add this to urls.py:

from cruds.urls import crud_for_app
urlpatterns += crud_for_app('testapp')

This will create following urls and appropriate views (assuming there is a application named testapp with model Author:

URL

name

/testapp/author/

testapp_author_list

/testapp/author/new/

testapp_author_create

/testapp/author/(?P<pk>d+)/

testapp_author_detail

/testapp/author/(?P<pk>d+)/edit/

testapp_author_update

/testapp/author/(?P<pk>d+)/remove/

testapp_author_delete

It is also possible to add CRUD for one model:

from django.db.models.loading import get_model
from cruds.urls import crud_for_model
urlpatterns += crud_for_model(get_model('testapp', 'Author'))

crud_fields templatetag displays fields for an object:

{% load crud_tags %}

<table class="table">
  <tbody>
    {% crud_fields object "name, description" %}
  </tbody>
</table>

Customizable CRUD url patterns crud_urls:

urlpatterns += crud_urls(
    Author,
    list_view=MyAuthorListView.as_view(),
    activate=ActivateAuthorView.as_view(),
)

Use cruds.util.crud_url shortcut function to quickly get url for instance for given action:

crud_url(author, 'update')

Is same as:

reverse('testapp_author_update', kwargs={'pk': author.pk})

cruds.util.crud_url accepts Model class as well for list actions, ie:

crud_url(Author, ‘list’) crud_url(Author, ‘create’)

cruds.util.crud_permission_name returns permission name using Django naming convention, ie: testapp.change_author.

Templates

django-cruds views will append CRUD template name to a list of default candidate template names for given action.

CRUD Templates are:

cruds/create.html
cruds/delete.html
cruds/detail.html
cruds/list.html
cruds/update.html

Quickstart

Install django-cruds:

pip install django-cruds

Then use it in a project, add cruds to INSTALLED_APPS.

Requirements

  • Django>=3.2<=4.0

Metadata

Release files for django-cruds 3.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-cruds 3.0.0
File Size Uploaded
django_cruds-3.0.0.tar.gz 13.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-cruds 3.0.0
File Interpreter ABI Platform
django_cruds-3.0.0-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 25.2 kB

Release files / django_cruds-3.0.0.tar.gz

Download URL django_cruds-3.0.0.tar.gz
Size 13.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9df7d093566c15c6e5c0992ae75cd628fd741251dac4fd672a10f12e12f24dd7
BLAKE2b-256 checksum
How to use checksums
6baed3eca8195cea6494a493946097537a6958ac5030ba5d6df86c78fd96511a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.10.4

Release files / django_cruds-3.0.0-py2.py3-none-any.whl

Download URL django_cruds-3.0.0-py2.py3-none-any.whl
Size 11.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
f46cb61ad2ee1bb90be274868056d376ee237f179b6537d6c8f4a17c3f426e37
BLAKE2b-256 checksum
How to use checksums
e3a8fbcb4345f10697c504e07e3af9287953830ea4dad3932abe0950144d3226
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.10.4

Release history Release notifications | RSS feed

This release

3.0.0 This release

2 release files

2.0.0

1 release file

1.2.0

1 release file

1.1.0

1 release file

1.0.0

1 release file

0.1.10

1 release file

0.1.9

1 release file

0.1.8

1 release file

0.1.7

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page