[Fixed]-Add a custom function to a M2M descendant

1👍

That is not the way to do it.

You may want to have a look at custom managers

0👍

This is wrong approach to define function on model, use custom managers for this.

Now problem is you can’t call a function from template(html page) call that function on view and render data in context.

With context data on view

_list_of_data = personne.types_permis2.all_valid()
{'_list_of_data':_list_of_data}

Now add this in context on render function

Then iterate over it on html

{% for item in _list_of_data %}
....
....
{% endfor %}

Leave a comment