pythondjangodjango-templatesdjango-tables2django-inplaceedit

Is there a way to use django-inplaceedit to do in-place editing of a column in django-tables2 TemplateColumn?


I tried to make a state_template.html with

{% load inplace_edit %}
{% block extra_header %}
    {% inplace_static %}
{% endblock %}
{% inplace_edit "action.action_state" %}

And tables.py has:

action_state = tables.TemplateColumn(template_name='django_tables2/state_template.html', verbose_name="State")

But since action is never being passed to the template, it is giving an error. Does anyone have any ideas on how to make this work?


Solution

  • This is a very nice question :-)

    I think if you update your template (state_template.html), with this should works:

    {% load inplace_edit %}
    
    {% block extra_header %}
        {% inplace_static %}
    {% endblock %}
    
    {% inplace_edit "record.action_state" %}
    

    And this is a recomendation, You should move to the template of the view that renderthe table, but this is only to efficiency:

    {% block extra_header %}
        {% inplace_static %}
    {% endblock %}