[PR #15005] [MERGED] 12795 custom user model #14499

Closed
opened 2025-12-29 23:24:50 +01:00 by adam · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbox-community/netbox/pull/15005
Author: @arthanson
Created: 2/1/2024
Status: Merged
Merged: 2/5/2024
Merged by: @jeremystretch

Base: featureHead: 12795-custom-user


📝 Commits (10+)

  • bf518d4 12795 users.User migration
  • 7897203 12795 users.User migration
  • 71c1e71 12795 review changes
  • 3af6dec 12795 fix user model registration
  • edf0dd6 12795 fix user model registration
  • ae454a8 12795 update migration
  • f3012e6 12795 update migration
  • 6358b42 12795 update migration
  • d0e3c39 12795 add comment to migration db_table
  • 26ca612 Tweak import to avoid class name collision

📊 Changes

19 files changed (+132 additions, -70 deletions)

View changed files

📝 netbox/netbox/navigation/menu.py (+3 -3)
📝 netbox/netbox/settings.py (+4 -0)
📝 netbox/templates/users/group.html (+1 -1)
📝 netbox/templates/users/objectpermission.html (+1 -1)
📝 netbox/templates/users/token.html (+1 -1)
netbox/users/admin.py (+0 -6)
📝 netbox/users/apps.py (+11 -0)
📝 netbox/users/forms/bulk_edit.py (+2 -2)
📝 netbox/users/forms/bulk_import.py (+1 -1)
📝 netbox/users/forms/filtersets.py (+2 -2)
📝 netbox/users/forms/model_forms.py (+1 -1)
📝 netbox/users/migrations/0001_squashed_0011.py (+28 -0)
📝 netbox/users/migrations/0002_squashed_0004.py (+0 -16)
netbox/users/migrations/0005_alter_user_table.py (+40 -0)
📝 netbox/users/models.py (+12 -11)
📝 netbox/users/tables.py (+3 -3)
📝 netbox/users/tests/test_views.py (+5 -5)
📝 netbox/users/urls.py (+6 -6)
📝 netbox/users/views.py (+11 -11)

📄 Description

Fixes: #12795

Did custom user model - dumped and compared SQL schemas and they look correct. Any extra testing suggestions welcome.

Did not do groups for several reasons:

  1. All suggestions (SO mostly) suggest just sub-classing Group: https://stackoverflow.com/questions/2181039/how-do-i-extend-the-django-group-model, https://www.reddit.com/r/django/comments/lvakzm/how_should_i_customize_the_group_model/ - Not sure if there is anything in Django that would be an issue with a custom group model (I don't think so off hand) but Django doesn't have any get_group_model like it does for User.
  2. There is no BaseGroup or AbstractBaseGroup - although Group model is very simple.
  3. There is an old Django ticket (https://code.djangoproject.com/ticket/29748) to allow swapping group model, although nothings been done in 2 years. Bit worried if we do a custom group and Django does theirs it will cause issues (though more minor concern).
  4. There is no pressing current need to have a custom Group, then only potential suggestion is for adding a description.
  5. Adding a description would not require anything besides subclassing it as it wouldn't be a perf hit, description would'nt be needed in perf critical areas.

Wouldn't be a big thing to convert Groups bug just some potential issues and not a big reason to do it right now IMHO. Also, an option is to potentially do the work for Django and submit a PR - though more work to handle the relation between customizable User and Group models.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbox-community/netbox/pull/15005 **Author:** [@arthanson](https://github.com/arthanson) **Created:** 2/1/2024 **Status:** ✅ Merged **Merged:** 2/5/2024 **Merged by:** [@jeremystretch](https://github.com/jeremystretch) **Base:** `feature` ← **Head:** `12795-custom-user` --- ### 📝 Commits (10+) - [`bf518d4`](https://github.com/netbox-community/netbox/commit/bf518d44e1f60c669c1651a4984e4d2c4e86413c) 12795 users.User migration - [`7897203`](https://github.com/netbox-community/netbox/commit/7897203723d12f9b9a88d7a744d35773a41d0812) 12795 users.User migration - [`71c1e71`](https://github.com/netbox-community/netbox/commit/71c1e7100af4cc39afd8057afd993f9b7b4fd78b) 12795 review changes - [`3af6dec`](https://github.com/netbox-community/netbox/commit/3af6dec748ac0ba5ec868f6fccdd96f1336c6377) 12795 fix user model registration - [`edf0dd6`](https://github.com/netbox-community/netbox/commit/edf0dd68dc5045a22cdd030f4404ec222d26d687) 12795 fix user model registration - [`ae454a8`](https://github.com/netbox-community/netbox/commit/ae454a8a0e9150b5bb0b00074f745e04bc11afaf) 12795 update migration - [`f3012e6`](https://github.com/netbox-community/netbox/commit/f3012e6931fe673a922d6df5fa5da79adb9d4675) 12795 update migration - [`6358b42`](https://github.com/netbox-community/netbox/commit/6358b4204b85f70858d8eccf63178cd952bf1459) 12795 update migration - [`d0e3c39`](https://github.com/netbox-community/netbox/commit/d0e3c399be927dbdb375498b15ec7ed1d9be2944) 12795 add comment to migration db_table - [`26ca612`](https://github.com/netbox-community/netbox/commit/26ca612880cfa179bad17e0a399d5ef2d9a0914e) Tweak import to avoid class name collision ### 📊 Changes **19 files changed** (+132 additions, -70 deletions) <details> <summary>View changed files</summary> 📝 `netbox/netbox/navigation/menu.py` (+3 -3) 📝 `netbox/netbox/settings.py` (+4 -0) 📝 `netbox/templates/users/group.html` (+1 -1) 📝 `netbox/templates/users/objectpermission.html` (+1 -1) 📝 `netbox/templates/users/token.html` (+1 -1) ➖ `netbox/users/admin.py` (+0 -6) 📝 `netbox/users/apps.py` (+11 -0) 📝 `netbox/users/forms/bulk_edit.py` (+2 -2) 📝 `netbox/users/forms/bulk_import.py` (+1 -1) 📝 `netbox/users/forms/filtersets.py` (+2 -2) 📝 `netbox/users/forms/model_forms.py` (+1 -1) 📝 `netbox/users/migrations/0001_squashed_0011.py` (+28 -0) 📝 `netbox/users/migrations/0002_squashed_0004.py` (+0 -16) ➕ `netbox/users/migrations/0005_alter_user_table.py` (+40 -0) 📝 `netbox/users/models.py` (+12 -11) 📝 `netbox/users/tables.py` (+3 -3) 📝 `netbox/users/tests/test_views.py` (+5 -5) 📝 `netbox/users/urls.py` (+6 -6) 📝 `netbox/users/views.py` (+11 -11) </details> ### 📄 Description ### Fixes: #12795 Did custom user model - dumped and compared SQL schemas and they look correct. Any extra testing suggestions welcome. Did not do groups for several reasons: 1. All suggestions (SO mostly) suggest just sub-classing Group: https://stackoverflow.com/questions/2181039/how-do-i-extend-the-django-group-model, https://www.reddit.com/r/django/comments/lvakzm/how_should_i_customize_the_group_model/ - Not sure if there is anything in Django that would be an issue with a custom group model (I don't think so off hand) but Django doesn't have any get_group_model like it does for User. 2. There is no BaseGroup or AbstractBaseGroup - although Group model is very simple. 3. There is an old Django ticket (https://code.djangoproject.com/ticket/29748) to allow swapping group model, although nothings been done in 2 years. Bit worried if we do a custom group and Django does theirs it will cause issues (though more minor concern). 4. There is no pressing current need to have a custom Group, then only potential suggestion is for adding a description. 5. Adding a description would not require anything besides subclassing it as it wouldn't be a perf hit, description would'nt be needed in perf critical areas. Wouldn't be a big thing to convert Groups bug just some potential issues and not a big reason to do it right now IMHO. Also, an option is to potentially do the work for Django and submit a PR - though more work to handle the relation between customizable User and Group models. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
adam added the pull-request label 2025-12-29 23:24:50 +01:00
adam closed this issue 2025-12-29 23:24:50 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#14499