Example #1
0
# tempset is now just the unique CCNs. We'll make a Course instance for each by 
# getting the first result of a query for Offerings with that CCN

for t in tempset:
    o = Offering.objects.filter(ccn=t)[:1]
    # o looks like a single object but is actually a queryset consisting of one record.
    # To  get the first actual object in it, use o[0]
    offering = o[0]
    print
    print offering
    
    # Create a Course record based on that
    course = Course()
    course.title = offering.title
    course.ccn = offering.ccn
    course.cstring = offering.cstring
    course.units = offering.units
    course.type = offering.type
    course.description = offering.description
    course.restrictions = offering.restrictions
    course.save()
    
    # Programs is many to many. Loop through and re-create
    for p in offering.programs.all():
        course.programs.add(p)
        
    # title = models.CharField(max_length=384)
    # ccn = models.CharField('CCN',max_length=384, blank=True)
    # cstring = models.ForeignKey(Cstring,verbose_name='Course String',help_text="e.g. J-200, but without the J")
    # units = models.IntegerField(choices=constants.UNIT_TYPE_CHOICES)
    # type = models.IntegerField(choices=constants.COURSE_TYPE_CHOICES)
Example #2
0
# tempset is now just the unique CCNs. We'll make a Course instance for each by
# getting the first result of a query for Offerings with that CCN

for t in tempset:
    o = Offering.objects.filter(ccn=t)[:1]
    # o looks like a single object but is actually a queryset consisting of one record.
    # To  get the first actual object in it, use o[0]
    offering = o[0]
    print
    print offering

    # Create a Course record based on that
    course = Course()
    course.title = offering.title
    course.ccn = offering.ccn
    course.cstring = offering.cstring
    course.units = offering.units
    course.type = offering.type
    course.description = offering.description
    course.restrictions = offering.restrictions
    course.save()

    # Programs is many to many. Loop through and re-create
    for p in offering.programs.all():
        course.programs.add(p)

    # title = models.CharField(max_length=384)
    # ccn = models.CharField('CCN',max_length=384, blank=True)
    # cstring = models.ForeignKey(Cstring,verbose_name='Course String',help_text="e.g. J-200, but without the J")
    # units = models.IntegerField(choices=constants.UNIT_TYPE_CHOICES)
    # type = models.IntegerField(choices=constants.COURSE_TYPE_CHOICES)