dpgaspar / Flask-AppBuilder

Simple and rapid application development framework, built on top of Flask. includes detailed security, auto CRUD generation for your models, google charts and much more. Demo (login with guest/welcome) - http://flaskappbuilder.pythonanywhere.com/
BSD 3-Clause "New" or "Revised" License
4.71k stars 1.36k forks source link

Question: What are the elements returned by the get method in widgets.get('list') in jinja2 templates? #2273

Open ejm4567 opened 1 month ago

ejm4567 commented 1 month ago

This is a question about how the following code in the template appbuilder/general/model/list.html works.

In the example quickhowto2 the template list_contacts.html has:

{% block list_list scoped %}
        Text before the list
        {{ super() }}
{% endblock %}

There is an extends command at the top of that template which extends the list.html template, referenced above. In list.html there is:

    {% block list_list scoped %}
        <div>
            {{ widgets.get('list')()|safe }}
        </div>
    {% endblock %}

In the views.py file for quickhowto2 the widgets MyListWidget or MyListWidgetOverride are used. Both of those classes have as the parent class ListWidget. It's not clear to me where the "list" that MyListWidget and/or ListWidget comes from.

Would it be correct to assume that the "list" being requested via widgets.get are in a sense a "row" of a form? Or is it something else ?

Any clarification/tips on how the above code is intended to work would be greatly appreciated!

Yoyasp commented 1 month ago

I'll check later when im behind my computer. But if my memory serve correctly the widget that is specified in the model/view is used. The default for this is the ListWidget (if the data used is fitting the widget)