Reputation: 39659
Here is my Model for Teacher class.
class Teacher(Profile):
class Meta:
db_table = 'teacher'
user = models.OneToOneField(User,
unique=True,
verbose_name=_('user'),
related_name='teacher')
home_address = models.CharField(_('home_address'), max_length=255, blank=True)
home_phone = models.CharField(_('home_phone'), max_length=30, blank=True)
cell_phone = models.CharField(_('cell_phone'), max_length=30, blank=True)
experience = models.IntegerField(default = 0)
summary = models.TextField(_('summary'), max_length=500, blank=True)
subjects = models.ManyToManyField(Subjects, through='SubjectsIntermediate')
When i execute the manage.py syncdb
it does creates the teacher
table with all fields except for field subjects
. Why the subjects
field is not created??
Upvotes: 3
Views: 1973
Reputation: 599490
Because a ManyToMany isn't a field, at least not one that exists as a database column. It's a relationship with a linking table. You'll find that a table named myapp_teacher_subjects
has been created, with foreign keys to both teacher and subjects.
Upvotes: 8