type object ... has no attribute ... when using formatters
See original GitHub issueHi, i’m using formatters for a model :
column_formatters = {
'name': macro('name_formatter')
}
With its template :
{% macro name_formatter(model, column) %}
{{ model.firstname }} {{ model.lastname }}
{% endmacro %}
Since flask-admin 1.4.1, i get this exception when running my application :
Traceback (most recent call last):
File "run.py", line 2, in <module>
from backend import app
File "/path/to/project/backend/__init__.py", line 68, in <module>
admin.create_admin(app)
File "/path/to/project/backend/views/admin.py", line 204, in create_admin
admin.add_view(OrderModelView(Order, db.session))
File "/path/to/project/lib/python2.7/site-packages/flask_admin/contrib/sqla/view.py", line 318, in __init__
menu_icon_value=menu_icon_value)
File "/path/to/project/lib/python2.7/site-packages/flask_admin/model/base.py", line 771, in __init__
self._refresh_cache()
File "/path/to/project/lib/python2.7/site-packages/flask_admin/model/base.py", line 847, in _refresh_cache
self._list_columns = self.get_list_columns()
File "/path/to/project/lib/python2.7/site-packages/flask_admin/model/base.py", line 980, in get_list_columns
excluded_columns=self.column_exclude_list,
File "/path/to/project/lib/python2.7/site-packages/flask_admin/contrib/sqla/view.py", line 517, in get_column_names
column, path = tools.get_field_with_path(self.model, c)
File "/path/to/project/lib/python2.7/site-packages/flask_admin/contrib/sqla/tools.py", line 144, in get_field_with_path
value = getattr(current_model, attribute)
AttributeError: type object 'Order' has no attribute 'name'
Version 1.4.0 works well.
Issue Analytics
- State:
- Created 7 years ago
- Comments:13 (5 by maintainers)
Top Results From Across the Web
AttributeError: 'NoneType' object has no attribute 'format'
Stack Overflow for Teams – Start collaborating and sharing organizational knowledge.
Read more >raise ModuleAttributeError("'{}' object has no attribute ...
raise ModuleAttributeError("'{}' object has no attribute '{}'".format( torch.nn.modules.module.ModuleAttributeError: 'Detect' object has no attribute 'm' #1055.
Read more >AttributeError: 'NoneType' object has no attribute 'format' - Reddit
Hi, I tried to make this loop work. But somehow I keep getting a NonType error. It seems that the format function fails...
Read more >AttributeError: 'NoneType' object has no attribute 'format'
print ("Hello World") print ("{} World").format(Hello). I'm working on my first "Hello World" program and I can get it to work by using...
Read more >Built-in Types — Python 3.11.1 documentation
Some operations are supported by several object types; in particular, ... Two more operations with the same syntactic priority, in and not in ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ah! Now it makes sense. Never thought of using it that way.
OK, I’ll restore old behavior and release 1.4.2 with a bug fix today. I can’t think of better way of defining list of visible columns in one place even if they’re virtual.
@mrjoes I would just like to mention that this behavior does not seem to be documented; and, in my opinion is extremely useful for setting “virtual” fields. A simple use case: