Skip to content

Instantly share code, notes, and snippets.

@tobz
Created September 22, 2016 15:44
Show Gist options
  • Save tobz/93bb62a84dfd76415764bbb37a78bb3d to your computer and use it in GitHub Desktop.
Save tobz/93bb62a84dfd76415764bbb37a78bb3d to your computer and use it in GitHub Desktop.
class CourseEnrollment(models.Model):
"""
Represents a Student's Enrollment record for a single Course. You should
generally not manipulate CourseEnrollment objects directly, but use the
classmethods provided to enroll, unenroll, or check on the enrollment status
of a given student.
We're starting to consolidate course enrollment logic in this class, but
more should be brought in (such as checking against CourseEnrollmentAllowed,
checking course dates, user permissions, etc.) This logic is currently
scattered across our views.
"""
MODEL_TAGS = ['course_id', 'is_active', 'mode']
user = models.ForeignKey(User)
course_id = CourseKeyField(max_length=255, db_index=True)
created = models.DateTimeField(auto_now_add=True, null=True, db_index=True)
_course_overview = models.ForeignKey(CourseOverview,
on_delete=models.DO_NOTHING,
db_column='course_id',
related_name='+',
db_index=False,
db_constraint=False,
)
ERRORS:
student.CourseEnrollment: (models.E007) Field '_course_overview' has column name 'course_id' that is used by another field.
HINT: Specify a 'db_column' for the field.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment