mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-17 04:58:16 -06:00
Fix ContentType resolution
This commit is contained in:
parent
cb61ed3277
commit
3d24239b68
@ -10,10 +10,9 @@ def update_custom_fields(apps, schema_editor):
|
|||||||
CustomField = apps.get_model('extras', 'CustomField')
|
CustomField = apps.get_model('extras', 'CustomField')
|
||||||
Group = apps.get_model('users', 'Group')
|
Group = apps.get_model('users', 'Group')
|
||||||
|
|
||||||
old_ct = ContentType.objects.get_by_natural_key('users', 'netboxgroup')
|
if old_ct := ContentType.objects.filter(app_label='users', model='netboxgroup').first():
|
||||||
new_ct = ContentType.objects.get_for_model(Group)
|
new_ct = ContentType.objects.get_for_model(Group)
|
||||||
|
CustomField.objects.filter(object_type=old_ct).update(object_type=new_ct)
|
||||||
CustomField.objects.filter(object_type=old_ct).update(object_type=new_ct)
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
@ -63,10 +62,6 @@ class Migration(migrations.Migration):
|
|||||||
field=models.ManyToManyField(blank=True, related_name='object_permissions', to='users.group'),
|
field=models.ManyToManyField(blank=True, related_name='object_permissions', to='users.group'),
|
||||||
),
|
),
|
||||||
|
|
||||||
migrations.DeleteModel(
|
|
||||||
name='NetBoxGroup',
|
|
||||||
),
|
|
||||||
|
|
||||||
# Delete groups from the old table
|
# Delete groups from the old table
|
||||||
migrations.RunSQL(
|
migrations.RunSQL(
|
||||||
"DELETE from auth_group"
|
"DELETE from auth_group"
|
||||||
@ -77,4 +72,9 @@ class Migration(migrations.Migration):
|
|||||||
code=update_custom_fields,
|
code=update_custom_fields,
|
||||||
reverse_code=migrations.RunPython.noop
|
reverse_code=migrations.RunPython.noop
|
||||||
),
|
),
|
||||||
|
|
||||||
|
# Delete the proxy model
|
||||||
|
migrations.DeleteModel(
|
||||||
|
name='NetBoxGroup',
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user