コード例 #1
0
ファイル: splitcourses.py プロジェクト: shacker/djcc
 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)
 # description = models.TextField()
 # restrictions = models.TextField(null=True,blank=True)
 # programs = models.ManyToManyField(Program,blank=True)
 
コード例 #2
0
    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)
    # description = models.TextField()
    # restrictions = models.TextField(null=True,blank=True)
    # programs = models.ManyToManyField(Program,blank=True)