question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

v1.0a1 AttributeError on changes_display_dict for ManyToOne relation

See original GitHub issue

When accessing the property changes_display_dict on a LogEntry with a ManyToOneRelation, I get the following error: (running with Django 3.1 and Python 3.8.5, and version 1.0a1 of auditlog.)

AttributeError                            Traceback (most recent call last)
<ipython-input-3-77e970a5d758> in <module>
      1 for h in history:
----> 2     print(h.changes_display_dict)
      3 

~/.virtualenvs/dashboard/lib/python3.8/site-packages/auditlog/models.py in changes_display_dict(self)
    259             # handle choices fields and Postgres ArrayField to get human readable version
    260             choices_dict = None
--> 261             if getattr(field, 'choices') and len(field.choices) > 0:
    262                 choices_dict = dict(field.choices)
    263             if hasattr(field, 'base_field') and isinstance(field.base_field, Field) and getattr(field.base_field, 'choices') and len(field.base_field.choices) > 0:

AttributeError: 'ManyToOneRel' object has no attribute 'choices'

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
viktor2097commented, Oct 1, 2021

@nanuxbe I closed it because it wasn’t supposed to be opened with the master branch. So right now there’s also a lot of other commits not relevant to the pull request. It seems like a lot of people are experiencing this issue, so I’ll open a new pull request with a proper branch and hopefully see it being merged sometime.

There’s nothing preventing this merge, as it has no impact on the code whatsoever, other than preventing a possible error.

I opened a new pull request #317

0reactions
hramezanicommented, Jun 9, 2022

I’m having this problem too

@tudoanh Could you please give me a small example that reproduces the problem?

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - AttributeError: 'dict' object has no attribute 'predictors'
when I changed all instances of "item(s)" in the code to "predictor(s)". Why is that so? # Return the Pearson correlation coefficient for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found