File tree 2 files changed +23
-1
lines changed
Section 22 - Advanced Topics - CBVs/testadvcbv/test_app 2 files changed +23
-1
lines changed Original file line number Diff line number Diff line change 1
1
from django .contrib import admin
2
-
2
+ from . models import School , Student
3
3
# Register your models here.
4
+ admin .site .register (School )
5
+ admin .site .register (Student )
Original file line number Diff line number Diff line change 1
1
from django .db import models
2
+ from django .urls import reverse
3
+ # SuperUserInformation
4
+ # User: Jose
5
+ # Email: training@pieriandata.com
6
+ # Password: testpassword
2
7
3
8
# Create your models here.
9
+ class School (models .Model ):
10
+ name = models .CharField (max_length = 256 )
11
+ principal = models .CharField (max_length = 256 )
12
+ location = models .CharField (max_length = 256 )
13
+
14
+ def __str__ (self ):
15
+ return self .name
16
+
17
+ class Student (models .Model ):
18
+ name = models .CharField (max_length = 256 )
19
+ age = models .PositiveIntegerField ()
20
+ school = models .ForeignKey (School ,related_name = 'students' ,on_delete = models .CASCADE )
21
+
22
+ def __str__ (self ):
23
+ return self .name
You can’t perform that action at this time.
0 commit comments