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.

'NoneType' object has no attribute 'attrs'

See original GitHub issue

I’m trying import-export on Django 3, python 3.8, on a fairly large site with lots of models, but I encounter this on the first class inspected in this code, which is import_export.resources.Resource.

    from import_export import resources
  File "/usr/lib/python3.8/site-packages/import_export/resources.py", line 234, in <module>
    class Resource(metaclass=DeclarativeMetaclass):
  File "/usr/lib/python3.8/site-packages/import_export/resources.py", line 202, in __new__
    setattr(meta, option, getattr(options, option))
AttributeError: 'NoneType' object has no attribute 'attrs'

When I add code to avoid that (if options:), I then encounter

    from import_export import resources
  File "/usr/lib/python3.8/site-packages/import_export/resources.py", line 986, in <module>
    class ModelResource(Resource, metaclass=ModelDeclarativeMetaclass):
  File "/usr/lib/python3.8/site-packages/import_export/resources.py", line 914, in __new__
    new_class = super().__new__(cls, name, bases, attrs)
  File "/usr/lib/python3.8/site-packages/import_export/resources.py", line 183, in __new__
    setattr(meta, option, getattr(options, option))
AttributeError: 'NoneType' object has no attribute 'attrs'

Again a guard if options: around that code helps.

  • Django Import Export: 2.0.2, 2.3.0, master
  • Python 3.8
  • Django 3.0.8

Odd packages which might be related are django-compat-patcher, and forbiddenfruit.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
juanjuxcommented, Aug 30, 2021

On forbiddenfruit.py we replaced:

calling_frame = inspect.currentframe().f_back
return sorted(calling_frame.f_locals.keys())

with:

return  __builtin__.dir(obj)

So it’s doing a dir(None) but that’s ok for our use case of the module.

0reactions
matthewhegartycommented, Sep 15, 2021

Fixed in #1325

Read more comments on GitHub >

github_iconTop Results From Across the Web

AttributeError: 'NoneType' object has no attribute 'attrs' [closed]
I am new to python. Please help me with this error. AttributeError: 'NoneType' object has no attribute 'attrs' from bs4 ...
Read more >
AttributeError: 'NoneType' object has no attribute 'attrs' · Issue ...
hello, i used the provided example in the 'examples' folder but i get the below error I logged in manually to linkedin and...
Read more >
Python – AttributeError: 'NoneType' object has no attribute 'attrs'
I am new to python. Please help me with this error. AttributeError: 'NoneType' object has no attribute 'attrs' from bs4 import BeautifulSoup import...
Read more >
How do I fix : attributeerror: 'nonetype' object has no attribute ...
When ever you get a problems that involves a message such as " 'nonetype' object has no attribute ..." it means the same...
Read more >
[FIXED] AttributeError: 'NoneType' object has no attribute ...
Hence, AttributeError: 'NoneType' object has no attribute 'something' error occurs when the type of object you are referencing is None.
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