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 student

0 0
Add a comment Improve this question Transcribed image text
Answer #1

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)

Add a comment
Know the answer?
Add Answer to:
DJANGO Question Please write the codes in models.py example: from __future__ import unicode_literals from django.db import...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • How to complete this methods: import java.io.FileInputStream; import java.io.FileNotFoundException; import java.time.Loc...

    How to complete this methods: import java.io.FileInputStream; import java.io.FileNotFoundException; import java.time.LocalDate; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Scanner; import java.util.Set; /** * Utility class that deals with all the other classes. * * @author EECS2030 Summer 2019 * */ public final class Registrar {    public static final String COURSES_FILE = "Courses.csv";    public static final String STUDENTS_FILE = "Students.csv";    public static final String PATH = System.getProperty("java.class.path");    /**    * Hash table to store the list of students using their...

  • Write a class called Course_xxx that represents a course taken at a school. Represent each student...

    Write a class called Course_xxx that represents a course taken at a school. Represent each student using the Student class from the Chapter 7 source files, Student.java. Use an ArrayList in the Course to store the students taking that course. The constructor of the Course class should accept only the name of the course. Provide a method called addStudent that accepts one Student parameter. Provide a method called roll that prints all students in the course. Create a driver class...

  • Help in database: User view requirement1: • For each student, store studentID, firstName, lastName, sex, majorDept,...

    Help in database: User view requirement1: • For each student, store studentID, firstName, lastName, sex, majorDept, class, GPA. Assuming you will need to access students based on their names. User view requirement2: • For each department, store deptId, deptName, college. In addition, store the studentId, firstName, lastName of students major in each department. Suppose a student belongs to one department only. A department will have more than one students. Assuming you will need to access departments based on their names....

  • JAVA PROGRAMMING In this final review lab from our intro course, use the Name class you...

    JAVA PROGRAMMING In this final review lab from our intro course, use the Name class you created in the previous lab. In this lab, create a Student class with the following class variable: Student name: Name (Note: Name is a datatype) Student Id: String Create the getter and setter methods. In addition to these methods, create a toString() method, which overrides the object class toString() method. This override method prints the current value of any of this class object. Complete...

  • package scheduler; import java.util.List; public class Scheduler { /** * Instantiates a new, empty scheduler. */...

    package scheduler; import java.util.List; public class Scheduler { /** * Instantiates a new, empty scheduler. */ public Scheduler() { } /** * Adds a course to the scheduler. * * @param course the course to be added */ public void addCourse(Course course) { } /** * Returns the list of courses that this scheduler knows about. * * This returned object does not share state with the internal state of the Scheduler. * * @return the list of courses */...

  • Here is the code from the previous three steps: #include <iostream> using namespace std; class Student...

    Here is the code from the previous three steps: #include <iostream> using namespace std; class Student { private: //class variables int ID; string firstName,lastName; public: Student(int ID,string firstName,string lastName) //constructor { this->ID=ID; this->firstName=firstName; this->lastName=lastName; } int getID() //getter method { return ID; } virtual string getType() = 0; //pure virtual function virtual void printInfo() //virtual function to print basic details of a student { cout << "Student type: " << getType() << endl; cout << "Student ID: " << ID...

  • what is the solution for this Java problem? Generics Suppose you need to process the following...

    what is the solution for this Java problem? Generics Suppose you need to process the following information regarding Students and Courses: A Student has a name, age, ID, and courseList. The class should have a constructor with inputs for setting name, ID and age. The class should have setters and getters for attributes name, ID and age, and a method addCourse, removeCourse, printSchedule. courseList: use the generic class ArrayList<E> as the type of this attribute addCourse: this method takes as...

  • Language Java Step 1: Design a class called Student. The Student class should contain the following...

    Language Java Step 1: Design a class called Student. The Student class should contain the following data: firstName lastName studentID totalCredits gpa Your class should implement the “sets” and “gets” for the class. Include methods: equals, compareTo, toString. Change the toString method (from class) to put each member variable on a new line. Step 2: Write a driver program to test that Student works correctly. Test is with 3 students as given in class. Step 3: Write a “registration” program...

  • I have a little problem about my code. when i'm working on "toString method" in "Course"...

    I have a little problem about my code. when i'm working on "toString method" in "Course" class, it always say there is a mistake, but i can not fix it: Student class: public class Student {    private String firstName;    private String lastName;    private String id;    private boolean tuitionPaid;       public Student(String firstName, String lastName, String id, boolean tuitionPaid)    {        this.firstName=firstName;        this.lastName=lastName;        this.id=id;        this.tuitionPaid=tuitionPaid;    }   ...

  • system analysis and design Class Diagram Scenario An instructor consists of name, address, email, number, and...

    system analysis and design Class Diagram Scenario An instructor consists of name, address, email, number, and salary. There can be either a full-time or part-time instructor. A student consists of name, student number, and email. Students can enroll for at least one seminar in a semester. Each seminar consists of seminar name, seminar number, and fees. Full-time instructors are responsible for taking the seminars. Each seminar can be taken by at least one and at most two instructors. Only two...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT