{% extends 'doc/en/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))),
]
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
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 %}