Skip to content

Commit a30c012

Browse files
committed
updates
1 parent 4cefd58 commit a30c012

File tree

13 files changed

+146
-0
lines changed

13 files changed

+146
-0
lines changed
Binary file not shown.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Generated by Django 3.0.3 on 2020-08-05 09:42
2+
3+
from django.db import migrations, models
4+
import django.db.models.deletion
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
initial = True
10+
11+
dependencies = [
12+
]
13+
14+
operations = [
15+
migrations.CreateModel(
16+
name='School',
17+
fields=[
18+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
19+
('name', models.CharField(max_length=256)),
20+
('principal', models.CharField(max_length=256)),
21+
('location', models.CharField(max_length=256)),
22+
],
23+
),
24+
migrations.CreateModel(
25+
name='Student',
26+
fields=[
27+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
28+
('name', models.CharField(max_length=256)),
29+
('age', models.PositiveIntegerField()),
30+
('school', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='students', to='test_app.School')),
31+
],
32+
),
33+
]
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!DOCTYPE html>
2+
{% load static %}
3+
<html>
4+
<head>
5+
<meta charset="utf-8">
6+
<title>
7+
CBVs
8+
{# Title Extensions go inside the block#}
9+
{% block title_block %}
10+
11+
{% endblock %}
12+
</title>
13+
14+
{# Bootstrap and CSS (Probably would want downloaded files in your real projects)#}
15+
{# https://bootswatch.com/#}
16+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
17+
integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
18+
19+
</head>
20+
<body>
21+
<nav class="navbar navbar-expand-lg navbar-light bg-light">
22+
<div class="navbar-nav">
23+
<a class="navbar-brand" href="{% url 'basic_app:list' %}">Schools</a>
24+
<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>
26+
</div>
27+
</nav>
28+
29+
<div class="container">
30+
{% block body_block %}
31+
32+
{% endblock %}
33+
</div>
34+
35+
</body>
36+
37+
{# Plugins#}
38+
39+
<!-- Latest compiled and minified jQuery -->
40+
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
41+
<!-- Latest compiled and minified JavaScript -->
42+
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
43+
</html>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{% extends "basic_app/basic_app_base.html" %}
2+
3+
{% block body_block %}
4+
<h1>Delete {{school.name}}?</h1>
5+
6+
<form method="post">
7+
{% csrf_token %}
8+
<input type="submit" class="btn btn-danger" value="Delete">
9+
<a href="{% url 'basic_app:detail' pk=school.pk %} ">Cancel</a>
10+
11+
</form>
12+
13+
{% endblock %}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{% extends "basic_app/basic_app_base.html" %}
2+
{% block body_block %}
3+
<div class="jumbotron">
4+
<h1>Welcome to the School Detail Page</h1>
5+
<h2>School Details:</h2>
6+
<p>Id_num: {{school_details.id}}</p>
7+
<p>Name: {{school_details.name}}</p>
8+
<p>Principal: {{school_details.principal}}</p>
9+
<p>Location: {{school_details.location}}</p>
10+
<h3>Students:</h3>
11+
12+
{% for student in school_details.students.all %}
13+
<p>{{student.name}} who is {{student.age}} years old.</p>
14+
{% endfor %}
15+
16+
</div>
17+
<div class="container">
18+
<p><a class='btn btn-warning' href="{% url 'basic_app:update' pk=school_details.pk %}">Update</a></p>
19+
20+
</div>
21+
22+
{% endblock %}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{% extends "basic_app/basic_app_base.html" %}
2+
3+
{% block body_block %}
4+
<h1>
5+
{% if not form.instance.pk %}
6+
Create School
7+
{% else %}
8+
Update School
9+
{% endif %}
10+
</h1>
11+
<form method="POST">
12+
{% csrf_token %}
13+
{{ form.as_p }}
14+
<input type="submit" class='btn btn-primary' value="Submit">
15+
16+
</form>
17+
18+
19+
{% endblock %}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{% extends "basic_app/basic_app_base.html" %}
2+
{% block body_block %}
3+
<div class="jumbotron">
4+
5+
<h1>Welcome to the List of Schools Page!</h1>
6+
<ol>
7+
{% for school in school_list %}
8+
<h2><li><a href="{{school.id}}/">{{school.name}} </a></li></h2>
9+
{% endfor %}
10+
</ol>
11+
12+
</div>
13+
14+
15+
{% endblock %}

Section 22 - Advanced Topics - CBVs/testadvcbv/testadvcbv/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
'django.contrib.sessions',
3838
'django.contrib.messages',
3939
'django.contrib.staticfiles',
40+
'test_app',
4041
]
4142

4243
MIDDLEWARE = [

0 commit comments

Comments
 (0)