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 | """
|
---|
15 | from django.db import models
|
---|
16 | from django.core.exceptions import ObjectDoesNotExist
|
---|
17 |
|
---|
18 |
|
---|
19 | class Base(models.Model):
|
---|
20 | ext_id = models.CharField(max_length=4)
|
---|
21 |
|
---|
22 | class SubclassA(Base):
|
---|
23 | info = models.TextField()
|
---|
24 |
|
---|
25 |
|
---|