- try:
- self.fields['parent'].queryset = instance_class.objects.exclude(id=instance.id)
- except ObjectDoesNotExist:
- pass
+
+ if instance_class is not None:
+ try:
+ self.fields['parent'].queryset = instance_class.objects.exclude(id=instance.id)
+ except ObjectDoesNotExist:
+ pass
+