[Answer]-Creating sitemap on Django error: object has no attribute '__getitem__'

1👍

You have two errors here.

obj will be a Dish instance, as returned by the items method. Model instances are like any other class instance, they use dot notation rather than square-bracket notation.

Secondly, your Dish model doesn’t have a slug attribute. So you can’t return it from the method.

Leave a comment