Ticket #2884: t2884.py

File t2884.py, 652 bytes (added by Simon G. <dev@…>, 18 years ago)
Line 
1from django.db import models
2
3class Subject(models.Model):
4 name = models.CharField(maxlength=40)
5
6class Course(models.Model):
7 name = models.CharField(maxlength=40)
8 subject = models.ForeignKey(Subject)
9 class Meta:
10 ordering = ["subject"]
11
12class Class(models.Model):
13 course = models.ForeignKey(Course)
14 name = models.CharField(maxlength = 40)
15
16 class Meta:
17 ordering = ["course"]
18
19
20__test__ = {'API_TESTS':"""
21>>> s = Subject(name='Web Apps')
22>>> s.save()
23>>> c = Course(name='Djangology', subject=s)
24>>> c.save()
25>>> cl = Class(course=c, name='Django 101')
26>>> cl.save()
27>>> Class.objects.all().order_by('course')
28[<Class: Class object>]
29"""}
Back to Top