Commit 64086d88 authored by Jay Lopez's avatar Jay Lopez

refactor to use function-based views

parent fd940423
......@@ -2,8 +2,8 @@ from django.conf.urls import url
from .views import *
urlpatterns = [
url(r'^heroes$', HomeView.as_view(), name='index'),
url(r'^hero/cloud$', CloudView.as_view()),
url(r'^hero/sunflowey$', SunfloweyView.as_view()),
url(r'^hero/jester$', JesterView.as_view())
url(r'^heroes$', home_page),
url(r'^hero/(cloud)$', detail_page),
url(r'^hero/(sunflowey)$', detail_page),
url(r'^hero/(jester)$', detail_page)
]
\ No newline at end of file
......@@ -3,17 +3,8 @@ from django.views.generic.base import TemplateView
# Create your views here.
class HomeView(TemplateView):
template_name = 'index.html'
def home_page(request):
return render(request, 'index.html')
class CloudView(TemplateView):
template_name = 'detail_cloud.html'
class JesterView(TemplateView):
template_name = 'detail_jester.html'
class SunfloweyView(TemplateView):
template_name = 'detail_sunflowey.html'
\ No newline at end of file
def detail_page(request, name):
return render(request, 'detail_' + name + '.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