urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^', include('Homepage.urls')),
url(r'^RepairLog/', include('RepairLog.urls')),
url(r'^RepairLog/DMRView/', TemplateView.as_view(template_name="RepairLog/DMRView.html"),name="dmr view"),
url(r'^RepairLog/DMRtab/', TemplateView.as_view(template_name="RepairLog/DMRtab.html"),name="dmrtab"),
url(r'^RepairLog/DMRwork/', TemplateView.as_view(template_name="RepairLog/DMRwork.html"),name="dmrwork"),
url(r'^Inventory/', include('Inventory.urls')),
url(r'^Inventory/inventory/<barcodething>/', TemplateView.as_view(template_name="Inventory/inventory.html"),name="inventory"),
url(r'^Inventory/inventory/', TemplateView.as_view(template_name="Inventory/inventory.html"),name="inventory"),
url(r'^Inventory/createitem/', TemplateView.as_view(template_name="Inventory/createItem.html"),name="createitem"),
url(r'^Inventory/manageitem/', TemplateView.as_view(template_name="Inventory/manageItem.html"),name="manageitem"),
url('accounts/', include('django.contrib.auth.urls')),] ##Necessary to login validation
Я пытаюсь получить доступ к штрихкоду в моем инвентаре. html шаблон. Я пытался {{barcodething}}
, но это не работает. Я использую URL-адрес http://127.0.0.1:8000/Inventory/inventory/123456789/
, который должен пройти barcodething=123456789
Если я удалю url(r'^Inventory/inventory/', TemplateView.as_view(template_name="Inventory/inventory.html"),name="inventory"),
или изменим его на: url(r'^Inventory/inventory/**$**', TemplateView.as_view(template_name="Inventory/inventory.html"),name="inventory"),
Тогда неожиданно возникает эта ошибка, которая может быть полезна в определении root причина:
`
Using the URLconf defined in MT.urls, Django tried these URL patterns, in this order:
^admin/
^ ^homepage/ [name='homepage']
^RepairLog/
^RepairLog/DMRView/ [name='dmr view']
^RepairLog/DMRtab/ [name='dmrtab']
^RepairLog/DMRwork/ [name='dmrwork']
^Inventory/ ^items/$ [name='item-list']
^Inventory/ ^items\.(?P<format>[a-z0-9]+)/?$ [name='item-list']
^Inventory/ ^items/(?P<pk>[^/.]+)/$ [name='item-detail']
^Inventory/ ^items/(?P<pk>[^/.]+)\.(?P<format>[a-z0-9]+)/?$ [name='item-detail']
^Inventory/ ^itemreorder/$ [name='item-list']
^Inventory/ ^itemreorder\.(?P<format>[a-z0-9]+)/?$ [name='item-list']
^Inventory/ ^itemreorder/(?P<pk>[^/.]+)/$ [name='item-detail']
^Inventory/ ^itemreorder/(?P<pk>[^/.]+)\.(?P<format>[a-z0-9]+)/?$ [name='item-detail']
^Inventory/ ^$ [name='api-root']
^Inventory/ ^\.(?P<format>[a-z0-9]+)/?$ [name='api-root']
^Inventory/inventory/<barcodething>/$ [name='inventory']
^Inventory/createitem/ [name='createitem']
^Inventory/manageitem/ [name='manageitem']
accounts/
The current path, Inventory/inventory/1/, didn't match any of these.`
Решение: Изменить url(r'^Inventory/inventory/<barcodething>/', TemplateView.as_view(template_name="Inventory/inventory.html"),name="inventory"),
TO: url(r'^Inventory/inventory/(?P<barcodething>[\w-]+)/', TemplateView.as_view(template_name="Inventory/inventory.html"),name="inventory"),