{% extends 'doc/en/base.html' %} {% load static %} {% block content %} {% verbatim %}

Blitz Work's 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))),
]

Blitz Work uses five URLs. (<crudname>/view), (<crudname>/detail), (<crudname>/create), (<crudname>/update), (<crudname>/delete).

When executing:


path('book/', include(get_urls(BookCRUD,"book"))),

The following URLs are created:


'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"]

The second parameter specified in the get_urls function (..., ...) corresponds to the name that will have the URL.This parameter can be omitted, when omitted Blitz Work will use The verbose_name of the specified model.

Al ejecutar:


path('book/', include(get_urls(BookCRUD))),

For this model:


class Book(models.Model):
    ...
    class Meta:
        verbose_name = "example"

The following URLs are created:


'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"]

You can access these URLs from a template as follows:


<a href="{% url 'example/view' %}">Books</a>
{% endverbatim %} {% endblock content %}