Closes #17166: Remove obsolete limit_choices_to argument from ForeignKey & M2M fields

This commit is contained in:
Jeremy Stretch
2025-04-03 09:17:20 -04:00
parent 6a966ee6c1
commit d93d398afa
30 changed files with 2 additions and 224 deletions

View File

@@ -505,28 +505,6 @@ class Migration(migrations.Migration):
model_name='cable',
name='termination_a_type',
field=models.ForeignKey(
limit_choices_to=models.Q(
models.Q(
models.Q(('app_label', 'circuits'), ('model__in', ('circuittermination',))),
models.Q(
('app_label', 'dcim'),
(
'model__in',
(
'consoleport',
'consoleserverport',
'frontport',
'interface',
'powerfeed',
'poweroutlet',
'powerport',
'rearport',
),
),
),
_connector='OR',
)
),
on_delete=django.db.models.deletion.PROTECT,
related_name='+',
to='contenttypes.contenttype',
@@ -536,28 +514,6 @@ class Migration(migrations.Migration):
model_name='cable',
name='termination_b_type',
field=models.ForeignKey(
limit_choices_to=models.Q(
models.Q(
models.Q(('app_label', 'circuits'), ('model__in', ('circuittermination',))),
models.Q(
('app_label', 'dcim'),
(
'model__in',
(
'consoleport',
'consoleserverport',
'frontport',
'interface',
'powerfeed',
'poweroutlet',
'powerport',
'rearport',
),
),
),
_connector='OR',
)
),
on_delete=django.db.models.deletion.PROTECT,
related_name='+',
to='contenttypes.contenttype',

View File

@@ -866,21 +866,6 @@ class Migration(migrations.Migration):
name='component_type',
field=models.ForeignKey(
blank=True,
limit_choices_to=models.Q(
('app_label', 'dcim'),
(
'model__in',
(
'consoleport',
'consoleserverport',
'frontport',
'interface',
'poweroutlet',
'powerport',
'rearport',
),
),
),
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name='+',
@@ -1238,21 +1223,6 @@ class Migration(migrations.Migration):
'component_type',
models.ForeignKey(
blank=True,
limit_choices_to=models.Q(
('app_label', 'dcim'),
(
'model__in',
(
'consoleporttemplate',
'consoleserverporttemplate',
'frontporttemplate',
'interfacetemplate',
'poweroutlettemplate',
'powerporttemplate',
'rearporttemplate',
),
),
),
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name='+',
@@ -1478,28 +1448,6 @@ class Migration(migrations.Migration):
(
'termination_type',
models.ForeignKey(
limit_choices_to=models.Q(
models.Q(
models.Q(('app_label', 'circuits'), ('model__in', ('circuittermination',))),
models.Q(
('app_label', 'dcim'),
(
'model__in',
(
'consoleport',
'consoleserverport',
'frontport',
'interface',
'powerfeed',
'poweroutlet',
'powerport',
'rearport',
),
),
),
_connector='OR',
)
),
on_delete=django.db.models.deletion.PROTECT,
related_name='+',
to='contenttypes.contenttype',

View File

@@ -31,13 +31,6 @@ class Migration(migrations.Migration):
'assigned_object_type',
models.ForeignKey(
blank=True,
limit_choices_to=models.Q(
models.Q(
models.Q(('app_label', 'dcim'), ('model', 'interface')),
models.Q(('app_label', 'virtualization'), ('model', 'vminterface')),
_connector='OR',
)
),
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name='+',

View File

@@ -259,7 +259,6 @@ class CableTermination(ChangeLoggedModel):
)
termination_type = models.ForeignKey(
to='contenttypes.ContentType',
limit_choices_to=CABLE_TERMINATION_MODELS,
on_delete=models.PROTECT,
related_name='+'
)

View File

@@ -751,7 +751,6 @@ class InventoryItemTemplate(MPTTModel, ComponentTemplateModel):
)
component_type = models.ForeignKey(
to='contenttypes.ContentType',
limit_choices_to=MODULAR_COMPONENT_TEMPLATE_MODELS,
on_delete=models.PROTECT,
related_name='+',
blank=True,

View File

@@ -1274,7 +1274,6 @@ class InventoryItem(MPTTModel, ComponentModel, TrackingModelMixin):
)
component_type = models.ForeignKey(
to='contenttypes.ContentType',
limit_choices_to=MODULAR_COMPONENT_MODELS,
on_delete=models.PROTECT,
related_name='+',
blank=True,

View File

@@ -1225,7 +1225,6 @@ class MACAddress(PrimaryModel):
)
assigned_object_type = models.ForeignKey(
to='contenttypes.ContentType',
limit_choices_to=MACADDRESS_ASSIGNMENT_MODELS,
on_delete=models.PROTECT,
related_name='+',
blank=True,

View File

@@ -3,7 +3,6 @@ from django.contrib.contenttypes.fields import GenericForeignKey
from django.core.exceptions import ValidationError
from django.db import models
from django.utils.translation import gettext_lazy as _
from dcim.constants import LOCATION_SCOPE_TYPES
__all__ = (
'CachedScopeMixin',
@@ -44,7 +43,6 @@ class CachedScopeMixin(models.Model):
scope_type = models.ForeignKey(
to='contenttypes.ContentType',
on_delete=models.PROTECT,
limit_choices_to=models.Q(model__in=LOCATION_SCOPE_TYPES),
related_name='+',
blank=True,
null=True