Me pregunto cómo puedo acceder a UpdateView usando un uuid como slug. Así que mi objetivo es una URL como
http://myapp.example.de/edit/7efdbb03-bdcf-4b8a-85dd-eb96ac9954fd
He definido la vista así:
class DeviceEventUploadView(UpdateView): model = Event slug_url_kwarg = 'uuid_slug' slug_field = 'unique_id'y urls.py así:
urlpatterns = [ path('admin/', admin.site.urls), path('edit/<uuid:uuid_slug>', DeviceEventUploadView.as_view(), name='event_update'), ]Aquí estoy recibiendo:
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.¿Dónde está mi fracaso al pensar?
Olvidaste cerrar <uuid:uuid_slug> . Necesita un paréntesis angular de cierre > . Además, esta es la sintaxis de path . Por lo tanto, define esto con:
path ( 'edit/ <uuid:uuid_slug> /', DeviceEventUploadView.as_view(), name='event_update' ),