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