define url patterns for various views

This commit is contained in:
Andreas Zweili 2017-12-25 13:31:29 +01:00
parent 3f6a9974ff
commit ce0143b274
2 changed files with 40 additions and 0 deletions

View File

@ -426,6 +426,30 @@ urlpatterns = [
path('admin/', admin.site.urls),
]
#+END_SRC
** inventory/urls.py
Contains the url definitions for the inventory application. For the
moment the inventory is my only application so all the URLs will start
from the root.
#+BEGIN_SRC python :tangle ../inventory/urls.py
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^device/(?P<device_id>[0-9]+)/$',
views.device_details,
name='device'),
url(r'^computer/(?P<computer_id>[0-9]+)/$',
views.computer_details,
name='computer'),
url(r'^cronjob/(?P<cronjob_id>[0-9]+)/$',
views.cronjob_details,
name='cronjob'),
]
#+END_SRC
* Templates

16
inventory/urls.py Normal file
View File

@ -0,0 +1,16 @@
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^device/(?P<device_id>[0-9]+)/$',
views.device_details,
name='device'),
url(r'^computer/(?P<computer_id>[0-9]+)/$',
views.computer_details,
name='computer'),
url(r'^cronjob/(?P<cronjob_id>[0-9]+)/$',
views.cronjob_details,
name='cronjob'),
]