[Django]-Error when using a custom template tag – object does not support item assignment

7πŸ‘

βœ…

You need to be passing a dictionary object from your inclusion tag to your inclusion tag template. It’s mentioned in the docs:

First, define the function that takes the argument and produces a dictionary of data for the result. The important point here is we only need to return a dictionary, not anything more complex.

so try:

@register.inclusion_tag('show.html')
def show_dep():
    return {
        'dep' : Depos.objects.all().order_by('?')[0]
    }

Leave a comment