[Answered ]-DoesNotExist at /rooms/create_room/ Room matching query does not exist (showing error in different function than the one im executing)

1👍

Look at your urls:

urlpatterns = [
    path('',views.rooms, name='rooms'),
    path('<slug:slug>/',views.room, name='room'),
    path('create_room/',views.room_form,name="create_room"),
]

Django is going from top to bottom here. Path rooms/create_room fits path('<slug:slug>/',views.room, name='room'), and there it is trying to work, but you have no Room with create_room slug I suppose, right? Put create_room view above the room view and it’s going to work better.

But, in advance, your room_form view is not going to work anyway. You are calling room variable without setting it before.

Leave a comment