django-popupcrud
                                
                                 django-popupcrud copied to clipboard
                                
                                    django-popupcrud copied to clipboard
                            
                            
                            
                        A CRUD framework that implements CRUD operations through HTML popups.
================ django-popupcrud
A CRUD framework leveraging Django's generic views that implements CRUD operations through HTML popups.
.. image:: https://img.shields.io/pypi/v/django-popupcrud.svg :target: https://pypi.python.org/pypi/django-popupcrud :alt: Latest PyPI version
.. image:: https://img.shields.io/pypi/dm/django-popupcrud.svg :target: https://pypi.python.org/pypi/django-popupcrud :alt: Number of PyPI downloads per month
Requirements
- Python >= 3.4
- Django >= 2.2.8
- django-bootstrap3
- django-pure-pagination
Documentation
Available at django-popupcrud.readthedocs.io <http://django-popupcrud.readthedocs.io/en/latest/index.html>_.
Quickstart
- 
Install django-popupcrudusing pip:pip install django-popupcrudOr install it directly from the source repository: pip install git+https://github.com/harikvpy/django-popupcrud.gitYet another way would be to clone this repository and install from the cloned root folder via pip install -e ..
- 
Install the dependencies - django-bootstrap3anddjango-pure-pagination. Add the dependencies andpopupcrudtoINSTALLED_APPSin your project'ssettings.py::INSTALLED_APPS = [ ... 'bootstrap3', 'pure_pagination', 'popupcrud', ... ]
- 
Let PopupCrudViewSetknow of your base template file name. This defaults tobase.html, but if your project uses a different base template filename, informPopupCrudViewSetabout it insettings.py::POPUPCRUD = { 'base_template': 'mybase.html', }Include Bootstrap CSS & JS resources in this base template. If you were to use {% bootstrap_css %} {% bootstrap_javascript %} {% block extrahead %}{% endblock extrahead %}django-bootstrap3tags for these, your base template should look something like this::Also, define a block named extraheadwithin the<head>element.PopupCrudViewSetviews use a few custom CSS styles to show column sorting options and sort priority. These styles are defined instatic/popupcrud/css/popupcrud.csswhich is inserted into theextraheadblock. If you don't declare this block, you will have to explicitly load the stylesheet into your base template.
- 
In your app's views.py, create aViewSetfor each model for which you want to support CRUD operations.Models.py:: from django.db import models class Author(models.Model): name = models.CharField("Name", max_length=128) penname = models.CharField("Pen Name", max_length=128) age = models.SmallIntegerField("Age", null=True, blank=True) class Meta: ordering = ('name',) verbose_name = "Author" verbose_name_plural = "Authors" def __str__(self): return self.nameViews.py:: from django.core.urlresolvers import reverse_lazy, reverse from popupcrud.views import PopupCrudViewSet class AuthorViewSet(PopupCrudViewSet): model = Author fields = ('name', 'penname', 'age') list_display = ('name', 'penname', 'age') list_url = reverse_lazy("library:authors:list") new_url = reverse_lazy("library:authors:create") def get_edit_url(self, obj): return reverse("library:authors:update", kwargs={'pk': obj.pk}) def get_delete_url(self, obj): return reverse("library:authors:delete", kwargs={'pk': obj.pk})
- 
Wire up the CRUD views generated by the viewset to the URLconf:: urlpatterns= [ url(r'^authors/', views.AuthorCrudViewset.urls()), ]This will register the following urls: - authors/- list view
- authors/create/- create view
- authors/<pk>/- detail view
- authors/<pk>/update/- update view
- authors/<pk>/delete/- delete view
 The urls are registered under its own namespace, which defaults to the model's verbose_name_pluralmeta value.
- 
Thats it! Your modern HTML popup based CRUD for your table is up and running. PopupCrudViewSet has many options to customize the fields displayed in list view, form used for create/update operations, permission control and more. Refer to the Reference and How-to sections of the documentation for more details. 
License
Distributed under BSD 3-Clause License. See LICENSE <LICENSE>_ file for details.