Ticket #7135: models-with-test-for-databrowse-and-inheritance.py

File models-with-test-for-databrowse-and-inheritance.py, 727 bytes (added by Andy MacKinlay, 16 years ago)

models.py which has a minimal doctest to reproduce the problem

Line 
1"""
2>>> from django.contrib.databrowse.datastructures import *
3>>> from django.contrib.databrowse.sites import *
4>>> from databrowse_inheritance.models import *
5>>> site = DatabrowseSite()
6>>> site.register(Base)
7>>> site.register(SubclassA)
8>>> b1 = Base.objects.create(ext_id='b1')
9>>> ei = EasyInstance(EasyModel(site, Base), b1)
10>>> # w/o the patch, this produces a DoesNotExist exception:
11>>> # due to trying to access the non-existent `subclassa` member of `b1`
12>>> print list(ei.related_objects())
13[]
14"""
15from django.db import models
16from django.core.exceptions import ObjectDoesNotExist
17
18
19class Base(models.Model):
20 ext_id = models.CharField(max_length=4)
21
22class SubclassA(Base):
23 info = models.TextField()
24
25
Back to Top