Made type inheritance a validation check for abstract references

This commit is contained in:
Ashley Whetter
2015-11-10 15:02:19 +00:00
parent 013227323d
commit f96e68cd11
2 changed files with 33 additions and 0 deletions

View File

@@ -996,6 +996,14 @@ class ReferenceField(BaseField):
self.error('You can only reference documents once they have been '
'saved to the database')
if self.document_type._meta.get('abstract') and \
not isinstance(value, self.document_type):
self.error('%s is not an instance of abstract reference'
' type %s' % (value._class_name,
self.document_type._class_name)
)
def lookup_member(self, member_name):
return self.document_type._fields.get(member_name)