Hello, about Python, django basics on the tryhello world site
I'm going to study and make a basic lecture bulletin board.
<:/p> at models.py
class Subject(models.Model):
subject_name = models.CharField(max_length=20)
def __str__(self):
return self.subject_name
class Professor(models.Model):
professor_name = models.CharField(max_length=10)
semester = models.Charfield(max_length=15)
subject = models.ForeignKey(Subject)
def __str__(self):
return self.professor_name
class Board(models.Model):
professor = models.ForeignKey(Professor):
def __str__(self):
return self.professor.professor_name
It's like this.
Here, one Professor
has one Subject
(1:1) form.
What I want is a form (1:N) that can have multiple subjects in one Professor
.
The goal is to
What should I do?
django python3
The current structure is not a 1:1 structure between the Professor and the Subject. Now, there is a 1:N structure with multiple Professioners per subject.
First, remove subject=models.ForeignKey(subject)
from classProfessor
.
And add professional = models.ForeignKey(Professional)
to class Subject
.
573 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
578 Understanding How to Configure Google API Key
922 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
613 GDB gets version error when attempting to debug with the Presense SDK (IDE)
623 Uncaught (inpromise) Error on Electron: An object could not be cloned
© 2024 OneMinuteCode. All rights reserved.