Skip to content

Commit 7349b68

Browse files
committed
updates
1 parent a30c012 commit 7349b68

File tree

8 files changed

+57
-7
lines changed

8 files changed

+57
-7
lines changed

Section 22 - Advanced Topics - CBVs/testadvcbv/test_app/templates/basic_app/school_confirm_delete.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% extends "basic_app/basic_app_base.html" %}
1+
{% extends "test_app/test_app_base.html" %}
22

33
{% block body_block %}
44
<h1>Delete {{school.name}}?</h1>

Section 22 - Advanced Topics - CBVs/testadvcbv/test_app/templates/basic_app/school_detail.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% extends "basic_app/basic_app_base.html" %}
1+
{% extends "test_app/test_app_base.html" %}
22
{% block body_block %}
33
<div class="jumbotron">
44
<h1>Welcome to the School Detail Page</h1>

Section 22 - Advanced Topics - CBVs/testadvcbv/test_app/templates/basic_app/school_form.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% extends "basic_app/basic_app_base.html" %}
1+
{% extends "test_app/test_app_base.html" %}
22

33
{% block body_block %}
44
<h1>

Section 22 - Advanced Topics - CBVs/testadvcbv/test_app/templates/basic_app/school_list.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{% extends "basic_app/basic_app_base.html" %}
1+
{% extends "test_app/test_app_base.html" %}
22
{% block body_block %}
33
<div class="jumbotron">
44

Section 22 - Advanced Topics - CBVs/testadvcbv/test_app/templates/basic_app/basic_app_base.html renamed to Section 22 - Advanced Topics - CBVs/testadvcbv/test_app/templates/basic_app/test_app_base.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
<body>
2121
<nav class="navbar navbar-expand-lg navbar-light bg-light">
2222
<div class="navbar-nav">
23-
<a class="navbar-brand" href="{% url 'basic_app:list' %}">Schools</a>
23+
<a class="navbar-brand" href="{% url 'test_app:list' %}">Schools</a>
2424
<a class="nav-item nav-link" href="{% url 'admin:index' %}">Admin</a>
25-
<a class="nav-item nav-link" href="{% url 'basic_app:create' %}">Create School</a>
25+
<a class="nav-item nav-link" href="{% url 'test_app:create' %}">Create School</a>
2626
</div>
2727
</nav>
2828

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from django.urls import path
2+
from . import views
3+
4+
app_name = 'test_app'
5+
6+
urlpatterns = [
7+
path('',views.SchoolListView.as_view(),name='list'),
8+
path('<int:pk>/',views.SchoolDetailView.as_view(),name='detail'),
9+
path('create/',views.SchoolCreateView.as_view(),name='create'),
10+
path('update/<int:pk>/',views.SchoolUpdateView.as_view(),name='update'),
11+
path('delete/<int:pk>/',views.SchoolDeleteView.as_view(),name='delete')
12+
]
Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,45 @@
11
from django.shortcuts import render
2-
from django.views.generic import View, TemplateView
2+
from django.urls import reverse_lazy
3+
from django.views.generic import (View,TemplateView,
4+
ListView,DetailView,)
35
from django.http import HttpResponse
6+
from . import models
47
# Create your views here.
58

9+
# Original Function View:
10+
#
11+
# def index(request):
12+
# return render(request,'index.html')
13+
#
14+
#
15+
16+
# Pretty simple right?
617
class IndexView(TemplateView):
18+
# Just set this Class Object Attribute to the template page.
19+
# template_name = 'app_name/site.html'
720
template_name = 'index.html'
21+
22+
def get_context_data(self,**kwargs):
23+
context = super().get_context_data(**kwargs)
24+
context['injectme'] = "Basic Injection!"
25+
return context
26+
27+
class SchoolListView(ListView):
28+
# If you don't pass in this attribute,
29+
# Django will auto create a context name
30+
# for you with object_list!
31+
# Default would be 'school_list'
32+
33+
# Example of making your own:
34+
# context_object_name = 'schools'
35+
model = models.School
36+
37+
38+
class SchoolDetailView(DetailView):
39+
context_object_name = 'school_details'
40+
model = models.School
41+
template_name = 'basic_app/school_detail.html'
42+
43+
class CBView(View):
44+
def get(self,request):
45+
return HttpResponse('Class Based Views are Cool!')

0 commit comments

Comments
 (0)