Django

Code

Ticket #7908: models.py

File models.py, 0.8 kB (added by rock@rockhoward.com, 6 months ago)

a models.py file that fails during validation

Line 
1 from django.db import models
2
3 # Abstract base classes with related models
4 #
5  
6 class Post(models.Model):
7         title = models.CharField(max_length=50)
8    
9 class Attachment(models.Model):
10     post = models.ForeignKey(Post, related_name='attached_%(class)s_set')
11     content = models.TextField()
12
13     class Meta:
14         abstract = True
15  
16     def __unicode__(self):
17         return self.content
18          
19 class Comment(Attachment):
20         is_spam = models.BooleanField()
21          
22 class Link(Attachment):
23         url = models.URLField()
24          
25 # Now we create a model with a ForeignKeu=y of an abstract class
26
27 class MyAttachment(models.Model):
28     mine = models.ForeignKey( Attachment )
29
30 # This fails to validate due to an internal error in related.py (line 605)
31 # fails in any recent trunk (i.e., rev 8506)