If you are using an authentication backend which is populating a value for the primary key weblate.auth.models.User.pk for new users, the check for creating the AuditLog is failing.
[X] I've searched for similar filed issues in this repository.
Steps to reproduce the behavior
This can be reproduced in a simple django python shell (python src/manage.py shell):
from django.contrib.auth import get_user_model
User = get_user_model()
User.objects.create(pk=42, username='test')
Expected behavior
A new user is created and the id - primary key is set to 42
Screenshots
No response
Exception traceback
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/Users/maltegerth/.local/share/poetry/virtualenvs/moll-translate-QA9TMEcw-py3.11/lib/python3.11/site-packages/django/db/models/manager.py", line 87, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/maltegerth/.local/share/poetry/virtualenvs/moll-translate-QA9TMEcw-py3.11/lib/python3.11/site-packages/django/db/models/query.py", line 658, in create
obj.save(force_insert=True, using=self.db)
File "/Users/maltegerth/.local/share/poetry/virtualenvs/moll-translate-QA9TMEcw-py3.11/lib/python3.11/site-packages/weblate/auth/models.py", line 421, in save
original = User.objects.get(pk=self.pk)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/maltegerth/.local/share/poetry/virtualenvs/moll-translate-QA9TMEcw-py3.11/lib/python3.11/site-packages/django/db/models/manager.py", line 87, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/maltegerth/.local/share/poetry/virtualenvs/moll-translate-QA9TMEcw-py3.11/lib/python3.11/site-packages/django/db/models/query.py", line 637, in get
raise self.model.DoesNotExist(
weblate.auth.models.User.DoesNotExist: User matching query does not exist.
This is never going to be supported. Weblate creates users internally as well (for bots or token access) and these will collide with externally managed primary key.
Describe the issue
If you are using an authentication backend which is populating a value for the primary key
weblate.auth.models.User.pk
for new users, the check for creating theAuditLog
is failing.I already tried
Steps to reproduce the behavior
This can be reproduced in a simple django python shell (
python src/manage.py shell
):Expected behavior
A new user is created and the
id
- primary key is set to42
Screenshots
No response
Exception traceback
How do you run Weblate?
Other
Weblate versions
Weblate deploy checks
No response
Additional context
No response