A Django app to conduct web-based bootstrap5, select2, CRUD, TABLE.
Project description
Modulo es una aplicacion de Django Para implementar el crud y tablas en bootstrap 5.2
Detailed documentation is in the “docs” directory.
Quick start
Add “modulo” to your INSTALLED_APPS setting like this:
pip install django-bt5-modulo add in settings.py INSTALLED_APPS = [ ... 'modulo', ]
Include the modulo URLconf in your project urls.py like this:
path('modulo/', include('modulo.urls')),
Run python manage.py migrate to create the modulo models.
Start the development server and visit https://github.com/xcarlx/plugin_django.git to create a poll (you’ll need the Admin app enabled).
Visit https://pypi.org/project/django-bootstrap5-modulo/ to participate in the poll.
Configuration
Configure template base:
<head> ... {% include 'modulo/formulario/styles.html' %} </head> <body> ... {% include 'modulo/formulario/modal.html' %} {% include 'modulo/formulario/scripts.html' %} </body>
Configure class view CRUD:
Configure forms class FormClass(forms.ModelForm): ... def __init__(self, *args, **kwargs): super(FormClass, self).__init__(*args, **kwargs) for field in self.fields: self.fields[field].widget.attrs['class'] = "form-control" Configure ClassView class ClassView(CreateView): # UpdateView, FormView ... template_name = "modulo/formulario/formulario.html" success_url = reverse_lazy('modulo:success', args=[0]) # or add in models get_absolute_url -> return reverse('modulo:success', kwargs={'pk': self.pk}) class EliminarView(DeleteView): ... template_name = "modulo/formulario/eliminar.html" success_url = reverse_lazy('modulo:success', kwargs={'pk': 0})
Configure ListView
* Create html table.html class ListaView(ListView): ... template_name = "table.html" def get_queryset(self): query = super(ListaView, self).get_queryset() search = self.request.GET.get("search") if search: query = query.filter( Q(name__icontains=search) | Q(othername__icontains=search) ) return query * Configure tamplate table.html {% extends 'modulo/formulario/lista.html' %} {% block titulo %} {% endblock %} {% block contenido_tabla %} <thead> <tr> <th class="text-center">HEAD</th> </tr> </thead> <tbody> {% for object in page_obj %} <tr> <td class="text-center"> {{ object.name }}</td> <td> <div class="btn-group"> <button class="btnEditar btn btn-primary btn-sm" data-pk="{{ object.pk }}"><span class="bi bi-pen"></span></button> <button class="btnEliminar btn btn-danger btn-sm" data-pk="{{ object.pk }}"><span class="bi bi-trash"></span></button> </div> </td> </tr> {% endfor %} </tbody> {% endblock %} {% block paginacion %} {% endblock %}
Configure basic JAVASCRIPT CRUD and LIST:
<script type="module"> import Modulo from "{% static 'modulo/js/modulo.js' %}"; import ListaView from "{% static 'modulo/js/lista.js' %}"; const formulario = document.getElementById("formModal"); {# get form #} const modal = document.getElementById("modalForm"); {# get modal #} const content = document.getElementById("contentElement"); {# content in to load table #} const modulo = new Modulo(); const lista = new ListaView(modulo, content, "{% url 'url_listview' %}"); lista.post_cargar_lista = () => { lista.botones("{% url 'url_create' %}", "{% url 'url_edit' 0 %}","{% url 'url_delete' 0 %}", "Test") } formulario.onsubmit = ev => lista.submit(ev); </script>
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django_bt5_modulo-0.6.1.tar.gz
.
File metadata
- Download URL: django_bt5_modulo-0.6.1.tar.gz
- Upload date:
- Size: 2.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4aebd785041ff0ab1f7ee3e57132362b548fdfe945b7b276f30e65b9b982c433 |
|
MD5 | b545664958c7581a60ce6be48ccd8d5a |
|
BLAKE2b-256 | fff0d6be4a754f4130e2bbfcd3928037ba44227be580f81b84fa1f4c534026de |
File details
Details for the file django_bt5_modulo-0.6.1-py3-none-any.whl
.
File metadata
- Download URL: django_bt5_modulo-0.6.1-py3-none-any.whl
- Upload date:
- Size: 3.2 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f41108b7e7c2b603c530b9e41e0df5c14bdb89cd6bfb0ec626c494d4af8cb96 |
|
MD5 | de78abb882470dc4db28224d08485d45 |
|
BLAKE2b-256 | dc932a1381e441fb238c4b8d591bd36f1a155eb286929b238d10b301d78f3840 |