PYTHON Question (Django) Please write python code (three classes) in order to te
ID: 3773485 • Letter: P
Question
PYTHON Question (Django)
Please write python code (three classes) in order to template
Write a web app for courses, teachers, and students application. You will have three models, one fore each of course, teacher, and student. A course can have a single teacher. A course can have many students enrolled in. A student can enrol in many courses. A course should have a name, code, classroom, and times. A teacher has a first and last name, office details, phone, and email. A student has a first and last name, and email.Explanation / Answer
from django.db import models
from django.contrib.auth.models import User
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _
class Student(models.Model):
first_name = models.CharField(max_length = 10)
last_name = models.CharField(max_length = 10)
email = models.EmailField(max_length = 50)
class Teacher(models.Model):
first_name = models.CharField(max_length = 10)
last_name = models.CharField(max_length = 10)
email = models.EmailField(max_length = 50)
phone = models.CharField(max_length = 10)
detials = models.CharField(max_length = 200)
class course(models.Model):
course_name = models.CharField(max_length = 50)
code = models.CharField(max_length = 10,primary_key = True)
classroom = models.CharField(max_length = 30)
teacher = models.ForeignKey(Teacher)
students = model.OnetoManyField()
time = models.DateTimeField(_("class hour"), default=timezone.now)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.