{% extends 'doc/es/base.html' %} {% block content %}

# Instalación

###### Instalar Blitz Work en consola.

    pip install blitz_work

# Cómo utilizar.

1. ###### Incluir Blitz Work en settings.py.

       INSTALLED_APPS = [
           ...,
           ...,
           'blitz_work',
       ]

2. ###### Crear modelos.

       from django.db import models

       class Author(models.Model):
           name = models.CharField(verbose_name="Nombre", max_length=255)
           birth_date = models.DateField(verbose_name="Fecha de nacimiento")

           class Meta:
               verbose_name = "Autor"
               verbose_name_plural = "Autores"

           def __str__(self):
               return self.name

       class Book(models.Model):
           title = models.CharField(verbose_name="Titulo", max_length=255)
           publication_date = models.DateField(verbose_name="Fecha de publicación")
           authors = models.ManyToManyField(Author,verbose_name="Autores")

           class Meta:
               verbose_name = "Libro"
               verbose_name_plural = "Libros"

           def __str__(self):
               return self.title

3. ###### Crear una plantilla.

                   {% verbatim %}
                   {% extends 'blitz_base_offline.html' %}
                   {% block main %}
                       <nav class="navbar navbar-expand-lg navbar-light bg-light">
                           <a class="navbar-brand" href="#">Test</a>
                           <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
                               <span class="navbar-toggler-icon"></span>
                           </button>
                           <div class="collapse navbar-collapse" id="navbarNavDropdown">
                               <ul class="navbar-nav">
                               <li class="nav-item">
                                   <a class="nav-link" href="{% url 'book/view' %}">Libros</a>
                               </li>
                               <li class="nav-item">
                                   <a class="nav-link" href="{% url 'author/view' %}">Autores</a>
                               </li>
                               </ul>
                           </div>
                       </nav>
                       {% block content %}{% endblock %}
                   {% endblock %}
                   {% endverbatim %}

4. ###### Crear las vistas.

       from Book.models import Author, Book
       from blitz_work.blitzcrud import BlitzCRUD

       class BookCRUD(BlitzCRUD):
           show_title = True
           show_caption = False
           caption_is_title = True
           extend_template = "base.html"
           data = Book

       class AuthorCRUD(BlitzCRUD):
           show_title = True
           show_caption = False
           caption_is_title = True
           extend_template = "base.html"
           data = Author

5. ###### Incluir las urls.

       from app.views import AuthorCRUD, BookCRUD
       from django.urls import path,include
       from blitz_work.blitzcrud import get_urls

       urlpatterns = [
           path('book/', include(get_urls(BookCRUD,"book"))),
           path('author/', include(get_urls(AuthorCRUD,"author"))),
       ]

6. ###### Resultado.

{% endblock content %}