Browse Source

Fixes #9156: Fix loading UserConfig data from fixtures

jeremystretch 3 years ago
parent
commit
1636508a6a
2 changed files with 4 additions and 3 deletions
  1. 1 0
      docs/release-notes/version-3.2.md
  2. 3 3
      netbox/users/models.py

+ 1 - 0
docs/release-notes/version-3.2.md

@@ -5,6 +5,7 @@
 ### Bug Fixes
 
 * [#9133](https://github.com/netbox-community/netbox/issues/9133) - Upgrade script should require Python 3.8 or later
+* [#9156](https://github.com/netbox-community/netbox/issues/9156) - Fix loading UserConfig data from fixtures
 
 ---
 

+ 3 - 3
netbox/users/models.py

@@ -173,11 +173,11 @@ class UserConfig(models.Model):
 
 
 @receiver(post_save, sender=User)
-def create_userconfig(instance, created, **kwargs):
+def create_userconfig(instance, created, raw=False, **kwargs):
     """
-    Automatically create a new UserConfig when a new User is created.
+    Automatically create a new UserConfig when a new User is created. Skip this if importing a user from a fixture.
     """
-    if created:
+    if created and not raw:
         config = get_config()
         UserConfig(user=instance, data=config.DEFAULT_USER_PREFERENCES).save()