Skip to content

Instantly share code, notes, and snippets.

@rana-ahmed
Created July 18, 2017 08:54
Show Gist options
  • Save rana-ahmed/9cd0548d7e87c3b172069d92577fe98e to your computer and use it in GitHub Desktop.
Save rana-ahmed/9cd0548d7e87c3b172069d92577fe98e to your computer and use it in GitHub Desktop.
from django.db import models
class Subject(models.Model):
name = models.CharField(max_length=128)
class Student(models.Model):
name = models.CharField(max_length=128)
subjects = models.ManyToManyField(Subject, through='StudentSubject')
class StudentSubject(models.Model):
student = models.ForeignKey(Student, on_delete=models.CASCADE)
subject = models.ForeignKey(Subject, on_delete=models.CASCADE)
marks = models.FloatField()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment