Created an error404 html file

to redirect users to an 'invalid' view when they click on items that
dont have an ongoing auction. Adjusted the views and urls python files
according to the redirection.
parent d93e5739
{% comment %} {% extends 'boodlesite\templates\base.html' %} {% endcomment %}
{% load static %}
{% block title %}{% endblock %}
{% block styles %}
{% endblock %}
{% block content %}
<h1>This auction has not started</h1>
<a href="/">Back to Home</a>
{% endblock %}
......@@ -6,4 +6,5 @@ urlpatterns = [
path('', homepage, name='index'),
path('auction', auction, name='auction'),
path('auction/<int:pk>/',auction,name='auctionid'),
path('error404', error404, name='error404'),
]
\ No newline at end of file
......@@ -71,6 +71,10 @@ def auction(request, pk):
if auction.auctionend < datetime.now():
return HttpResponse("This auction has already passed.")
elif auction.auctionstart > datetime.now():
return HttpResponse("This auction has not yet started.")
#return HttpResponse("This auction has not yet started.")
return render(request, "boodlesite/templates/error404.html")
else:
return render(request, "boodlesite/templates/auction.html",context)
def error404(request):
return render(request, "boodlesite/templates/error404.html")
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment