I'm wondering on how I can access a UpdateView by using a uuid as slug. So my goal is an URL like
http://myapp.example.de/edit/7efdbb03-bdcf-4b8a-85dd-eb96ac9954fd
I have defined the the view like this:
class DeviceEventUploadView(UpdateView):
model = Event
slug_url_kwarg = 'uuid_slug'
slug_field = 'unique_id'
and urls.py like this:
urlpatterns = [
path('admin/', admin.site.urls),
path('edit/<uuid:uuid_slug>',
DeviceEventUploadView.as_view(),
name='event_update'),
]
Here I'm getting:
Using the URLconf defined in myproject.urls, Django tried these URL patterns, in this order:
admin/
^edit/<uuid:uuid_slug> [name='event_update']
The current path, edit/7efdbb03-bdcf-4b8a-85dd-eb96ac9954fd/, didn’t match any of these.
Where is my failure in thinking?
CodePudding user response:
You forgot to close the <uuid:uuid_slug>
. It needs a closing angle bracket >
. Furthermore this is path
syntax. You thus define this with:
path(
'edit/<uuid:uuid_slug>/',
DeviceEventUploadView.as_view(),
name='event_update'
),