Skip to content
This repository has been archived by the owner on Jan 22, 2022. It is now read-only.

Commit

Permalink
Merge pull request #90 from tejas15802/master
Browse files Browse the repository at this point in the history
Attempting to fix error handling
  • Loading branch information
0xtejas authored Mar 27, 2021
2 parents 67e3cb1 + 64e22e5 commit d42e148
Show file tree
Hide file tree
Showing 6 changed files with 163 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ db.sqlite3
.vscode
vir
python3
mysite.log
35 changes: 34 additions & 1 deletion cognizance_cms/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
SECRET_KEY = '-l_p92!kg)+ptgu0-83-)u=x+y+nd4vu(_f&*o2!36#@vd5sr6'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
DEBUG = False

ALLOWED_HOSTS = ['cognizance-amrita.herokuapp.com','127.0.0.1']

Expand Down Expand Up @@ -177,3 +177,36 @@

django_heroku.settings(locals())

# LOGGING IN PRODUCTION STATE
# LOGGING = {
# 'version': 1,
# 'disable_existing_loggers': False,
# 'formatters': {
# 'verbose': {
# 'format' : "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s",
# 'datefmt' : "%d/%b/%Y %H:%M:%S"
# },
# 'simple': {
# 'format': '%(levelname)s %(message)s'
# },
# },
# 'handlers': {
# 'file': {
# 'level': 'DEBUG',
# 'class': 'logging.FileHandler',
# 'filename': 'mysite.log',
# 'formatter': 'verbose'
# },
# },
# 'loggers': {
# 'django': {
# 'handlers':['file'],
# 'propagate': True,
# 'level':'DEBUG',
# },
# 'MYAPP': {
# 'handlers': ['file'],
# 'level': 'DEBUG',
# },
# }
# }
2 changes: 2 additions & 0 deletions cognizance_cms/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@
path('membersapp/', include('membersapp.urls')),
]

handler404 = 'pages.views.error_404_view'
handler500 = 'pages.views.error_500_view'
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
60 changes: 60 additions & 0 deletions pages/templates/pages/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<html>
<style>
@import url('https://fonts.googleapis.com/css?family=Nunito+Sans');
:root {
--blue: #0e0620;
--white: #fff;
}

html,
body {
height: 100%;
}

body {
background: url("https://wallpapercave.com/wp/wp4194085.png") no-repeat left top;
background-size: cover;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
font-family: "Nunito Sans";
color: var(--blue);
font-size: 1em;
}

ul {
list-style-type: none;
padding-inline-start: 35px;
}

h1 {
font-size: 7.5em;
margin: 15px 0px;
font-weight: bold;
}

h2 {
font-weight: bold;
}

@media screen and (max-width:768px) {
body {
display: block;
}
.container {
margin-top: 70px;
margin-bottom: 70px;
}
}
</style>
<h< class="col-md-6 align-self-center">
<h1 style="color:#fff;">Error "404"</h1style>
<h2 style="color:#fff;"> You're lost.</h2>
<h3 style="color:#fff;">The page you are looking for does not exist.</h3>
<h3 style="color:#fff;"> But you can click the button below to go back to the homepage.</h3>
</div>
<a class="btn" type="submit" href="{% url 'home' %}" style="text-align:center; background-color:#fff;border-radius:30px;border-color:#fff;width:150px;height:40px;padding:10px;font-weight:bold;font-family:Nunito Sans;border: none;font-size:medium;letter-spacing: 2.5px;">HOME</a>
</div>

</html>
61 changes: 61 additions & 0 deletions pages/templates/pages/500.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<html>
<style>
@import url('https://fonts.googleapis.com/css?family=Nunito+Sans');
:root {
--blue: #0e0620;
--white: #fff;
}

html,
body {
height: 100%;
}

body {
background: url("https://wallpapercave.com/wp/wp4194085.png") no-repeat left top;
background-size: cover;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
font-family: "Nunito Sans";
color: var(--blue);
font-size: 1em;
}

ul {
list-style-type: none;
padding-inline-start: 35px;
}

h1 {
font-size: 7.5em;
margin: 15px 0px;
font-weight: bold;
}

h2 {
font-weight: bold;
}

@media screen and (max-width:768px) {
body {
display: block;
}
.container {
margin-top: 70px;
margin-bottom: 70px;
}
}
</style>
<h class="col-md-6 align-self-center">
<h1 style="color:#fff;">Error "500"</h1>
<h2 style="color:#fff;"> Internal Server Error.</h2>
<h3 style="color:#fff;">Sorry, something went wrong on our end. We are currently trying to fix the problem.</h3>
<h3 style="color:#fff;"> But you can click the button below to go back to the homepage.</h3>
<a class="btn" type="submit" href="{% url 'home' %}" style="text-align:center; background-color:#fff;border-radius:30px;border-color:#fff;width:150px;height:40px;padding:10px;font-weight:bold;font-family:Nunito Sans;border: none;font-size:medium;letter-spacing: 2.5px;">HOME</a>
</h>

</div>

</html>
5 changes: 5 additions & 0 deletions pages/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
from adminapp.models import Achievement

# Create your views here.
def error_404_view(request,exception):
return render(request,'404.html')

def error_500_view(request):
return render(request,'pages/500.html')

def home(request):
return render(request, 'pages/index.html')
Expand Down

0 comments on commit d42e148

Please sign in to comment.