added fix for OneToOneRel error happening in case of Polymorphic model (#429)

This commit is contained in:
Rahul Prasad 2022-09-21 12:23:10 +05:30 committed by GitHub
parent d74c118834
commit a56d0e6f78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 2 deletions

View file

@ -9,6 +9,7 @@
- fix: Display `created` timestamp in server timezone ([#404](https://github.com/jazzband/django-auditlog/pull/404))
- fix: Handle port in `remote_addr` ([#417](https://github.com/jazzband/django-auditlog/pull/417))
- fix: Handle the error with AttributeError: 'OneToOneRel' error occur during a `PolymorphicModel` has relation with other models ([#429](https://github.com/jazzband/django-auditlog/pull/429))
## 2.1.1 (2022-07-27)

View file

@ -70,7 +70,11 @@ def get_field_value(obj, field):
else:
value = smart_str(getattr(obj, field.name, None))
except ObjectDoesNotExist:
value = field.default if field.default is not NOT_PROVIDED else None
value = (
field.default
if getattr(field, "default", NOT_PROVIDED) is not NOT_PROVIDED
else None
)
return value

View file

@ -1145,7 +1145,6 @@ class ChoicesFieldModelTest(TestCase):
)
def test_changes_display_dict_single_choice(self):
self.assertEqual(
self.obj.history.latest().changes_display_dict["status"][1],
"Red",