Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ class Migration(migrations.Migration):
name='termination_type',
field=models.ForeignKey(
blank=True,
limit_choices_to=models.Q(
('model__in', ('region', 'sitegroup', 'site', 'location', 'providernetwork'))
),
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name='+',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class Migration(migrations.Migration):
name='member_type',
field=models.ForeignKey(
on_delete=django.db.models.deletion.PROTECT,
limit_choices_to=models.Q(('app_label', 'circuits'), ('model__in', ['circuit', 'virtualcircuit'])),
related_name='+',
to='contenttypes.contenttype',
blank=True,
Expand All @@ -68,7 +67,6 @@ class Migration(migrations.Migration):
model_name='circuitgroupassignment',
name='member_type',
field=models.ForeignKey(
limit_choices_to=models.Q(('app_label', 'circuits'), ('model__in', ['circuit', 'virtualcircuit'])),
on_delete=django.db.models.deletion.PROTECT,
related_name='+',
to='contenttypes.contenttype'
Expand Down
2 changes: 0 additions & 2 deletions netbox/circuits/models/circuits.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ class CircuitGroupAssignment(CustomFieldsMixin, ExportTemplatesMixin, TagsMixin,
"""
member_type = models.ForeignKey(
to='contenttypes.ContentType',
limit_choices_to=CIRCUIT_GROUP_ASSIGNMENT_MEMBER_MODELS,
on_delete=models.PROTECT,
related_name='+'
)
Expand Down Expand Up @@ -249,7 +248,6 @@ class CircuitTermination(
termination_type = models.ForeignKey(
to='contenttypes.ContentType',
on_delete=models.PROTECT,
limit_choices_to=Q(model__in=CIRCUIT_TERMINATION_TERMINATION_TYPES),
related_name='+',
blank=True,
null=True
Expand Down
44 changes: 0 additions & 44 deletions netbox/dcim/migrations/0003_squashed_0130.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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',
Expand Down
52 changes: 0 additions & 52 deletions netbox/dcim/migrations/0131_squashed_0159.py
Original file line number Diff line number Diff line change
Expand Up @@ -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='+',
Expand Down Expand Up @@ -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='+',
Expand Down Expand Up @@ -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',
Expand Down
7 changes: 0 additions & 7 deletions netbox/dcim/migrations/0199_macaddress.py
Original file line number Diff line number Diff line change
Expand Up @@ -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='+',
Expand Down
1 change: 0 additions & 1 deletion netbox/dcim/models/cables.py
Original file line number Diff line number Diff line change
Expand Up @@ -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='+'
)
Expand Down
1 change: 0 additions & 1 deletion netbox/dcim/models/device_component_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion netbox/dcim/models/device_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion netbox/dcim/models/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions netbox/dcim/models/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
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',
Expand Down Expand Up @@ -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
Expand Down
6 changes: 0 additions & 6 deletions netbox/ipam/migrations/0001_squashed.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,6 @@ class Migration(migrations.Migration):
'scope_type',
models.ForeignKey(
blank=True,
limit_choices_to=models.Q(
(
'model__in',
('region', 'sitegroup', 'site', 'location', 'rack', 'clustergroup', 'cluster'),
)
),
null=True,
on_delete=django.db.models.deletion.CASCADE,
to='contenttypes.contenttype',
Expand Down
7 changes: 0 additions & 7 deletions netbox/ipam/migrations/0002_squashed_0046.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,6 @@ class Migration(migrations.Migration):
name='assigned_object_type',
field=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='+',
Expand Down
8 changes: 0 additions & 8 deletions netbox/ipam/migrations/0047_squashed_0053.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,6 @@ class Migration(migrations.Migration):
name='assigned_object_type',
field=models.ForeignKey(
blank=True,
limit_choices_to=models.Q(
models.Q(
models.Q(('app_label', 'dcim'), ('model', 'interface')),
models.Q(('app_label', 'ipam'), ('model', 'fhrpgroup')),
models.Q(('app_label', 'virtualization'), ('model', 'vminterface')),
_connector='OR',
)
),
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name='+',
Expand Down
8 changes: 0 additions & 8 deletions netbox/ipam/migrations/0054_squashed_0067.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,14 +304,6 @@ class Migration(migrations.Migration):
(
'assigned_object_type',
models.ForeignKey(
limit_choices_to=models.Q(
models.Q(
models.Q(('app_label', 'dcim'), ('model', 'interface')),
models.Q(('app_label', 'ipam'), ('model', 'vlan')),
models.Q(('app_label', 'virtualization'), ('model', 'vminterface')),
_connector='OR',
)
),
on_delete=django.db.models.deletion.PROTECT,
related_name='+',
to='contenttypes.contenttype',
Expand Down
1 change: 0 additions & 1 deletion netbox/ipam/migrations/0071_prefix_scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class Migration(migrations.Migration):
name='scope_type',
field=models.ForeignKey(
blank=True,
limit_choices_to=models.Q(('model__in', ('region', 'sitegroup', 'site', 'location'))),
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name='+',
Expand Down
1 change: 0 additions & 1 deletion netbox/ipam/models/ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -742,7 +742,6 @@ class IPAddress(ContactsMixin, PrimaryModel):
)
assigned_object_type = models.ForeignKey(
to='contenttypes.ContentType',
limit_choices_to=IPADDRESS_ASSIGNMENT_MODELS,
on_delete=models.PROTECT,
related_name='+',
blank=True,
Expand Down
1 change: 0 additions & 1 deletion netbox/ipam/models/vlans.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ class VLANGroup(OrganizationalModel):
scope_type = models.ForeignKey(
to='contenttypes.ContentType',
on_delete=models.CASCADE,
limit_choices_to=Q(model__in=VLANGROUP_SCOPE_TYPES),
blank=True,
null=True
)
Expand Down
14 changes: 0 additions & 14 deletions netbox/users/migrations/0001_squashed_0011.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,20 +132,6 @@ class Migration(migrations.Migration):
(
'object_types',
models.ManyToManyField(
limit_choices_to=models.Q(
models.Q(
models.Q(
(
'app_label__in',
['account', 'admin', 'auth', 'contenttypes', 'sessions', 'taggit', 'users'],
),
_negated=True,
),
models.Q(('app_label', 'auth'), ('model__in', ['group', 'user'])),
models.Q(('app_label', 'users'), ('model__in', ['objectpermission', 'token'])),
_connector='OR',
)
),
related_name='object_permissions',
to='contenttypes.ContentType',
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,6 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='objectpermission',
name='object_types',
field=models.ManyToManyField(
limit_choices_to=models.Q(
models.Q(
models.Q(
(
'app_label__in',
['account', 'admin', 'auth', 'contenttypes', 'sessions', 'taggit', 'users'],
),
_negated=True,
),
models.Q(('app_label', 'auth'), ('model__in', ['group', 'user'])),
models.Q(('app_label', 'users'), ('model__in', ['objectpermission', 'token'])),
_connector='OR',
)
),
related_name='object_permissions',
to='core.objecttype',
),
field=models.ManyToManyField(related_name='object_permissions', to='core.objecttype'),
),
]
18 changes: 1 addition & 17 deletions netbox/users/migrations/0009_update_group_perms.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,6 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='objectpermission',
name='object_types',
field=models.ManyToManyField(
limit_choices_to=models.Q(
models.Q(
models.Q(
(
'app_label__in',
['account', 'admin', 'auth', 'contenttypes', 'sessions', 'taggit', 'users'],
),
_negated=True,
),
models.Q(('app_label', 'users'), ('model__in', ['objectpermission', 'token', 'group', 'user'])),
_connector='OR',
)
),
related_name='object_permissions',
to='core.objecttype',
),
field=models.ManyToManyField(related_name='object_permissions', to='core.objecttype'),
),
]
Loading