Reputation: 12592
Greetings, I'm sure there is a simple solution to what I'm trying to do but unfortunately I wasn't able to find it in the documentation.
I have the following model (simplified version shown):
models.py:
class Student(models.Model):
student_id = models.IntegerField(primary_key=True, unique=True,
db_index=True, max_length=9)
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
def __unicode__(self):
return u"%s %s" % (self.first_name, self.last_name)
class Course(models.Model):
course_id = models.AutoField(primary_key=True, unique=True,
db_index=True, max_length=4)
title = models.CharField(max_length=50)
dept = models.CharField(max_length=6)
number = models.IntegerField(max_length=5)
student_id = models.ManyToManyField(Student, blank=True)
def __unicode__(self):
return u"%s %s" % (self.dept, self.number)
What I wanted was to be able to add students to multiple classes in the admin interface similar to the way that I can add students in the classes admin interface. If there is yet another way that seems more beneficial I would be interested in that as well.
Thanks in advance for any help!
Upvotes: 1
Views: 372