Page not found (404): The current path, calendars/event/1/details, didn’t match any of these
admin/
accounts/
calendars/ add/ [name='calendar_add']
calendars/ <int:calendar_id>/events/add/ [name='event_add']
calendars/ event/<int:event_id>/details/ [name='EventDetailsView']
calendars/ <int:calendar_id>/events/all/ [name='EventListView']
calendars/ <int:calendar_id>/details/ [name='CalendarDetailView']
The current path, calendar/event/1/details, didn’t match any of these.
In my urls.py in calendar app it is working for all other urls:
app_name = 'calendars'
urlpatterns = [
path('add/', login_required(CalendarCreateView.as_view()), name='calendar_add'), # working
path('<int:calendar_id>/events/add/', login_required(EventCreateView.as_view()), name='event_add'), # working
path('event/<int:event_id>/details/ ', EventDetailsView.as_view(), name='EventDetailsView'), #NOT working
# path('event/1/details/ ', EventDetailsView.as_view(), name='EventDetailsView'),
# path('<int:calendar_id>/details/', login_required(calendar_details.as_view()), name='details'),
path('<int:calendar_id>/events/all/', EventListView.as_view(), name='EventListView'), # working
path('<int:calendar_id>/details/', CalendarDetailView.as_view(), name='CalendarDetailView'), # working
]
and the view for this is :
class EventDetailsView(FormView):
def get(self, request, event_id):
# # Check if the event exists
# Check if the request is authenticated
if request.user.is_authenticated:
# event = request.event
event = get_object_or_404(Event, id=event_id)
# Return full event details if authenticated
data = {
"id": event.id,
"name": event.name,
"description": event.description,
"date": str(event.date),
"start_time": str(event.start_time),
"duration": event.duration,
"last_modified": str(event.last_modified)
}
return JsonResponse(data)
where I am trying to return the info of a specific event with fields: id, name, description, date, start_time, duration, last_modified
Here is just the authenticated part of the view. This view for unauthenticated requests, the name and description values should be changed to empty strings. Also, if the given ID is not associated with any calendar or event, you should return a 404 NOT FOUND response.
