Skip to content

Commit 61dc74b

Browse files
committed
Updates
1 parent 3b20433 commit 61dc74b

21 files changed

+39
-28
lines changed
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from django import forms
2-
from .models import User
2+
from appTwo.models import User
33

44
class NewUserForm(forms.ModelForm):
55
class Meta:
66
model = User
7-
fields = '__all__'
7+
fields = '__all__'

Section 18 - Django Level Three/ProTwo/appTwo/migrations/0001_initial.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated by Django 2.0.5 on 2018-08-31 18:34
1+
# Generated by Django 3.0.3 on 2020-07-27 07:40
22

33
from django.db import migrations, models
44

Section 18 - Django Level Three/ProTwo/appTwo/migrations/__init__.py

Whitespace-only changes.

Section 18 - Django Level Three/ProTwo/appTwo/templates/appTwo/help.html

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<head>
44
<meta charset="utf-8">
55
<title>HELP PAGE</title>
6+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
67
</head>
78
<body>
89
{{ help_insert }}

Section 18 - Django Level Three/ProTwo/appTwo/templates/appTwo/index.html

+7-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
<head>
44
<meta charset="utf-8">
55
<title>Home</title>
6+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
67
</head>
78
<body>
8-
<h1>Welcome!</h1>
9-
<h2>Go to /users to see the list of user information!</h2>
10-
9+
<div class='container'>
10+
<div class="jumbotron">
11+
<h1>Welcome!</h1>
12+
<h2>Go to /users to see the list of user information!</h2>
13+
</div>
14+
</div>
1115
</body>
1216
</html>

Section 18 - Django Level Three/ProTwo/appTwo/templates/appTwo/users.html

+11-13
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,21 @@
33
<head>
44
<meta charset="utf-8">
55
<title>Users</title>
6+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
67
</head>
78
<body>
8-
<h1>Here are your users:</h1>
9+
<div class="container">
10+
<div class='jumbotron'>
911

10-
{% if users %}
12+
<h1>Sign up:</h1>
1113

12-
<ol>
13-
{% for person in users %}
14-
<li>User Info</li>
15-
<ul>
16-
<li>First Name: {{person.first_name}}</li>
17-
<li>Last Name: {{person.last_name}}</li>
18-
<li>Email: {{person.email}}</li>
19-
</ul>
20-
{% endfor %}
21-
</ol>
14+
<form method="POST">
15+
{{ form.as_p }}
16+
{% csrf_token %}
17+
<input type="submit" class="btn btn-primary" value="Submit">
18+
</form>
2219

23-
{% endif %}
20+
</div>
21+
</div>
2422
</body>
2523
</html>

Section 18 - Django Level Three/ProTwo/appTwo/views.py

+15-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from django.shortcuts import render
2-
from django.http import HttpResponse
3-
from .models import User
2+
from appTwo.forms import NewUserForm
3+
# from django.http import HttpResponse
4+
# from .models import User
45

56
# Create your views here.
67
# def index(request):
@@ -14,6 +15,15 @@ def index(request):
1415
return render(request,'appTwo/index.html')
1516

1617
def users(request):
17-
user_list = User.objects.order_by('first_name')
18-
user_dict = {"users":user_list}
19-
return render(request,'appTwo/users.html',context=user_dict)
18+
form = NewUserForm()
19+
20+
if request.method == 'POST':
21+
form = NewUserForm(request.POST)
22+
23+
if form.is_valid():
24+
form.save(commit=True)
25+
return index(request)
26+
else:
27+
print('ERROR FORM INVALID')
28+
29+
return render(request, 'appTwo/users.html', {'form':form})
Binary file not shown.

Section 18 - Django Level Three/studyProject/studyApp/templates/studyApp/form_page.html

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<title>Forms</title>
7-
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
8-
integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
7+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
98
</head>
109
<body>
1110

Section 18 - Django Level Three/studyProject/studyApp/templates/studyApp/index.html

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<title>Home</title>
7-
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
8-
integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
7+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
98
</head>
109
<body>
1110
<div class="container">

0 commit comments

Comments
 (0)