Skip to content

Fix 500 error that occurred when no fields changed - #994

Open
U-238 wants to merge 1 commit into
etianen:masterfrom
U-238:master
Open

Fix 500 error that occurred when no fields changed#994
U-238 wants to merge 1 commit into
etianen:masterfrom
U-238:master

Conversation

@U-238

@U-238 U-238 commented Jan 2, 2026

Copy link
Copy Markdown

Using Django 6.0 and django-reversion 6.1.0, I was getting a 500 error when saving a model where no fields had changed. This PR fixes this bug.

@etianen

etianen commented Jun 17, 2026

Copy link
Copy Markdown
Owner

Sorry, I just noticed this pr 😮

Can you provide a traceback for the error this fixes? It would be good to verify that this fixes the problem before merging it blind 😄

@U-238

U-238 commented Jul 4, 2026

Copy link
Copy Markdown
Author

Hi @etianen, no problem. I've just confirmed the bug still exists in django-reversion 6.3.0, running on Python 3.12 with Django 6.0.6. Here is the stack trace:

Traceback (most recent call last):
  File "/home/me/code/sytycb/.venv/lib/python3.12/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/home/me/code/sytycb/.venv/lib/python3.12/site-packages/django/core/handlers/base.py", line 198, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/me/code/sytycb/.venv/lib/python3.12/site-packages/django/contrib/admin/options.py", line 711, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/me/code/sytycb/.venv/lib/python3.12/site-packages/django/utils/decorators.py", line 192, in _view_wrapper
    result = _process_exception(request, e)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/me/code/sytycb/.venv/lib/python3.12/site-packages/django/utils/decorators.py", line 190, in _view_wrapper
    response = view_func(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/me/code/sytycb/.venv/lib/python3.12/site-packages/django/views/decorators/cache.py", line 80, in _view_wrapper
    response = view_func(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/me/code/sytycb/.venv/lib/python3.12/site-packages/django/contrib/admin/sites.py", line 247, in inner
    return view(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/me/code/sytycb/.venv/lib/python3.12/site-packages/reversion/admin.py", line 180, in change_view
    return super().change_view(request, object_id, form_url, extra_context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/me/code/sytycb/.venv/lib/python3.12/site-packages/django/contrib/admin/options.py", line 1946, in change_view
    return self.changeform_view(request, object_id, form_url, extra_context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/me/code/sytycb/.venv/lib/python3.12/site-packages/django/utils/decorators.py", line 48, in _wrapper
    return bound_method(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/me/code/sytycb/.venv/lib/python3.12/site-packages/django/utils/decorators.py", line 192, in _view_wrapper
    result = _process_exception(request, e)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/me/code/sytycb/.venv/lib/python3.12/site-packages/django/utils/decorators.py", line 190, in _view_wrapper
    response = view_func(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/me/code/sytycb/.venv/lib/python3.12/site-packages/django/contrib/admin/options.py", line 1802, in changeform_view
    return self._changeform_view(request, object_id, form_url, extra_context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/me/code/sytycb/.venv/lib/python3.12/site-packages/django/contrib/admin/options.py", line 1862, in _changeform_view
    self.log_change(request, new_object, change_message)
  File "/home/me/code/sytycb/.venv/lib/python3.12/site-packages/reversion/admin.py", line 97, in log_change
    set_comment(entry.get_change_message())
                ^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'get_change_message'

Then I tried applying the same fix as in this PR, and the bug no longer occurred.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants