users: Creating a user account that belongs to a group fails
When creating a new users in System -> Users -> Create, if any groups are selected from the list of groups, the operation fails with the following stack trace. This happens with Django version 3:4.2.10-1 currently in testing. This is likely due to changes in Django to methods/classes that are not considered public API.
Internal Server Error: /plinth/sys/users/create/
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/django/db/models/fields/__init__.py", line 2053, in get_prep_value
return int(value)
^^^^^^^^^^
ValueError: invalid literal for int() with base 10: 'git-access'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/django/views/generic/base.py", line 104, in view
return self.dispatch(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/django/views/generic/base.py", line 143, in dispatch
return handler(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/django/views/generic/edit.py", line 184, in post
return super().post(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/django/views/generic/edit.py", line 153, in post
return self.form_valid(form)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/django/contrib/messages/views.py", line 12, in form_valid
response = super().form_valid(form)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/django/views/generic/edit.py", line 135, in form_valid
self.object = form.save()
^^^^^^^^^^^
File "/freedombox/plinth/modules/users/forms.py", line 141, in save
user = super().save(commit)
^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/django/contrib/auth/forms.py", line 153, in save
self.save_m2m()
File "/usr/lib/python3/dist-packages/django/forms/models.py", line 525, in _save_m2m
f.save_form_data(self.instance, cleaned_data[f.name])
File "/usr/lib/python3/dist-packages/django/db/models/fields/related.py", line 1956, in save_form_data
getattr(instance, self.attname).set(data)
File "/usr/lib/python3/dist-packages/django/db/models/fields/related_descriptors.py", line 1228, in set
else self.target_field.get_prep_value(obj)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/django/db/models/fields/related.py", line 1135, in get_prep_value
return self.target_field.get_prep_value(value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3/dist-packages/django/db/models/fields/__init__.py", line 2055, in get_prep_value
raise e.__class__(
ValueError: Field 'id' expected a number but got 'git-access'.