django-auditlog
django-auditlog copied to clipboard
LogEntry.log_create writes to read-only database
We are using a primary/replica database configuration in our production environment described like here: https://docs.djangoproject.com/en/4.0/topics/db/multi-db/
I have an issue where LogEntry is written to the read-only database. After some research I found the cause of this issue:
https://github.com/jazzband/django-auditlog/blob/master/auditlog/models.py#L70
By setting the database via .using() it omits the database router.
Anybody knows a solutions for this issue? (And why is the database set this way in de the code?)
We are having the same problem here.
I think the lib could just use self.create(**kwargs). And let the developer decide which database he will write the object to by setting the DATABASE_ROUTERS.
It sounds like a good idea?
I would like to know why the database is configured this way in the code.
Fixed in https://github.com/jazzband/django-auditlog/commit/77ef852706ccfa8523f8de98e886fc9097e252d4