[GH-ISSUE #602] Cannot edit LDAP-user #352

Closed
opened 2026-02-27 15:58:21 +03:00 by kerem · 5 comments
Owner

Originally created by @thofram on GitHub (Sep 22, 2023).
Original GitHub issue: https://github.com/retspen/webvirtcloud/issues/602

When I try to edit a user created by LDAP-logon, I get this error:
ERROR: Internal Server Error: /admin/users/2/update/

I cannot make this LDAP user an admin.

Originally created by @thofram on GitHub (Sep 22, 2023). Original GitHub issue: https://github.com/retspen/webvirtcloud/issues/602 When I try to edit a user created by LDAP-logon, I get this error: ERROR: Internal Server Error: /admin/users/2/update/ I cannot make this LDAP user an admin.
kerem closed this issue 2026-02-27 15:58:21 +03:00
Author
Owner

@thofram commented on GitHub (Sep 22, 2023):

From /srv/webvirtcloud/webvirtcloud.log:

[2023-09-22 15:26:33,112] ERROR: Internal Server Error: /admin/users/2/update/ Traceback (most recent call last): File "/srv/webvirtcloud/venv/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner response = get_response(request) ^^^^^^^^^^^^^^^^^^^^^ File "/srv/webvirtcloud/venv/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/webvirtcloud/admin/decorators.py", line 8, in _inner return function(request, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/webvirtcloud/admin/views.py", line 120, in user_update attributes = UserAttributes.objects.get(user=user) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/webvirtcloud/venv/lib/python3.11/site-packages/django/db/models/manager.py", line 87, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/webvirtcloud/venv/lib/python3.11/site-packages/django/db/models/query.py", line 637, in get raise self.model.DoesNotExist( accounts.models.UserAttributes.DoesNotExist: UserAttributes matching query does not exist.

<!-- gh-comment-id:1731438570 --> @thofram commented on GitHub (Sep 22, 2023): From /srv/webvirtcloud/webvirtcloud.log: `[2023-09-22 15:26:33,112] ERROR: Internal Server Error: /admin/users/2/update/ Traceback (most recent call last): File "/srv/webvirtcloud/venv/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner response = get_response(request) ^^^^^^^^^^^^^^^^^^^^^ File "/srv/webvirtcloud/venv/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/webvirtcloud/admin/decorators.py", line 8, in _inner return function(request, *args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/webvirtcloud/admin/views.py", line 120, in user_update attributes = UserAttributes.objects.get(user=user) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/webvirtcloud/venv/lib/python3.11/site-packages/django/db/models/manager.py", line 87, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/srv/webvirtcloud/venv/lib/python3.11/site-packages/django/db/models/query.py", line 637, in get raise self.model.DoesNotExist( accounts.models.UserAttributes.DoesNotExist: UserAttributes matching query does not exist.`
Author
Owner

@catborise commented on GitHub (Sep 22, 2023):

@krejcar25 do you have any fix/recommendation. Thanks

<!-- gh-comment-id:1731897586 --> @catborise commented on GitHub (Sep 22, 2023): @krejcar25 do you have any fix/recommendation. Thanks
Author
Owner

@krejcar25 commented on GitHub (Sep 22, 2023):

will check tomorrow @catborise @thofram

<!-- gh-comment-id:1731903022 --> @krejcar25 commented on GitHub (Sep 22, 2023): will check tomorrow @catborise @thofram
Author
Owner

@krejcar25 commented on GitHub (Sep 23, 2023):

this is caused by incorrect use of Django User models. developers are supposed to extend the builtin User model and add attributes this way (doc). the way it's implemented here is through a sidecar model which django-auth-ldap does not know it should create. i will try and find a workaround.

<!-- gh-comment-id:1732237539 --> @krejcar25 commented on GitHub (Sep 23, 2023): this is caused by incorrect use of Django User models. developers are supposed to extend the builtin User model and add attributes this way ([doc](https://docs.djangoproject.com/en/4.2/topics/auth/customizing/#extending-the-existing-user-model)). the way it's implemented here is through a sidecar model which django-auth-ldap does not know it should create. i will try and find a workaround.
Author
Owner

@thofram commented on GitHub (Sep 24, 2023):

Thank you, I can edit the userprofiles of LDAP-users now.

<!-- gh-comment-id:1732575174 --> @thofram commented on GitHub (Sep 24, 2023): Thank you, I can edit the userprofiles of LDAP-users now.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/webvirtcloud#352
No description provided.