Skip to content

Commit

Permalink
return 404
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-yin committed Jun 6, 2024
1 parent adf11b4 commit d278c31
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/django_lookbook/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,18 @@ def inspect_view(request, slug):

preview_name, example_name = slug.split("/")

preview_cls = get_previews()[preview_name.replace("_component", "")]
preview_cls = get_previews().get(preview_name.replace("_component", ""), None)
if not preview_cls:
return render(
request,
"django_lookbook/404.html",
context={
"sidebar_previews": sidebar_previews,
"previews": get_previews(),
},
status=404,
)

preview_instance = preview_cls()

query_dict = request_get_to_dict(request)
Expand Down Expand Up @@ -240,7 +251,10 @@ def preview_view(request, slug):

preview_name, example_name = slug.split("/")

preview_cls = get_previews()[preview_name.replace("_component", "")]
preview_cls = get_previews().get(preview_name.replace("_component", ""), None)
if not preview_cls:
raise Http404

preview_instance = preview_cls()

query_dict = request_get_to_dict(request)
Expand Down

0 comments on commit d278c31

Please sign in to comment.