mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-26 09:16:10 -06:00
added ct_field and fk_field null validation
This commit is contained in:
parent
ac81f741a0
commit
5aae5a68f2
@ -67,6 +67,15 @@ class NetBoxModel(CloningMixin, NetBoxFeatureSet, models.Model):
|
||||
|
||||
for field in self._meta.get_fields():
|
||||
if isinstance(field, GenericForeignKey):
|
||||
if getattr(self, field.ct_field) is None and getattr(self, field.fk_field) is not None:
|
||||
raise ValidationError({
|
||||
field.ct_field: "This field cannot be null.",
|
||||
})
|
||||
if getattr(self, field.fk_field) is None and getattr(self, field.ct_field) is not None:
|
||||
raise ValidationError({
|
||||
field.fk_field: "This field cannot be null.",
|
||||
})
|
||||
|
||||
if getattr(self, field.ct_field) and getattr(self, field.fk_field):
|
||||
klass = getattr(self, field.ct_field).model_class()
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user