{% extends 'doc/es/base.html' %} {% load static %} {% block content %} {% verbatim %}
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))),
]
Al ejecutar:
path('book/', include(get_urls(BookCRUD,"book"))),
Se crean las siguientes urls:
'book/view/' [name= "book/view"]
'book/create/' [name= "book/create"]
'book/detail/' [name= "book/detail"]
'book/update/' [name= "book/update"]
'book/delete/' [name= "book/delete"]
El segundo parámetro especificado en la función get_urls(...,...) corresponde a el nombre
que tendrá la url. Este parámetro puede ser omitido, al ser omitido
Al ejecutar:
path('book/', include(get_urls(BookCRUD))),
Para este modelo:
class Book(models.Model):
...
class Meta:
verbose_name = "example"
Se crean las siguientes urls:
'book/view/' [name= "example/view"]
'book/create/' [name= "example/create"]
'book/detail/' [name= "example/detail"]
'book/update/' [name= "example/update"]
'book/delete/' [name= "example/delete"]
Se puede acceder a estas url desde una plantilla de la siguiente forma:
<a href="{% url 'example/view' %}">Libros</a>
{% endverbatim %}
{% endblock content %}