DJANGO Question Please write the codes in models.py example: from __future__ imp
ID: 3773453 • Letter: D
Question
DJANGO Question
Please write the codes in models.py
example:
from __future__ import unicode_literals from django.db import models class Course(models.Model): name = models.CharField(max_length=30) code = models.CharField(max_length=30) classroom = models.CharField(max_length=30) time = models.DateField() teacher = models.OneToOneField(Teacher) class Teacher(models.Model): firstname = models.CharField(max_length=30) lastname = models.CharField(max_length=30) office_details = models.CharField(max_length=30) phone = models.CharField(max_length=30) email = models.EmailField(max_length=30) class Student(models.Model): firstname = models.CharField(max_length=30) lastname = models.CharField(max_length=30) email = models.EmailField(max_length=30) courses = models.ManyToManyField(Course)Please change these codes. 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
Note: given example code is as it is avilabe in dijango as per the requirement
from django.db import models
class Course(models.Model):
name = models.CharField(max_length=30)
code = models.CharField(max_length=30)
classroom = models.CharField(max_length=30)
time = models.DateField()
teacher = models.OneToOneField(Teacher)
class Teacher(models.Model):
firstname = models.CharField(max_length=30)
lastname = models.CharField(max_length=30)
office_details = models.CharField(max_length=30)
phone = models.CharField(max_length=30)
email = models.EmailField(max_length=30)
class Student(models.Model):
firstname = models.CharField(max_length=30)
lastname = models.CharField(max_length=30)
email = models.EmailField(max_length=30)
courses = models.ManyToManyField(Course)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.