Monday, December 21, 2015

Django Model | Relationship question. Student->School Class

With this code for example.

    class Students(models.Model):
        first_name = models.CharField(max_length=30)
        last_name = models.CharField(max_length=30)
        classChoice1 = ?
        classChoice2 = ?
        classChouce3 = ?   
   
    class Class(models.Model):
        class_name = models.CharField(max_length=30)
        class_discription = models.CharField(max_length=30)   


Say for example I have Nth students, S1 S2 S3 ... and Nth classes (as in college class) C1 C2 C3 ...
And I want to create a relationship where each student can only be assigned to one class uniquely for each classChoice
selected. How would I create that relationship?


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7f6cfec3-8fc0-4353-a0a8-7d73a7b3e3e4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment