0

This is my code:

class Predict(views.APIView):
    def post(self, request):
        employeeId = 44
        return render(request, 'InventoryShop/home.html', {'employeeId': employeeId})

What I want to achieve is to output this employeeId on the home.html, from this scope. But this code gives an error when trying to run it:

context must be a dict rather than set.

When I put this employeeId outside the scope, I am able to output it without problem though:

def home(request):
    context = {
        'employeeId' : employeeId
    }
    return render(request, 'InventoryShop/home.html', context)

Edit: I'm aware of the changes from 1.8 to 1.11

Ralf
  • 16,086
  • 4
  • 44
  • 68
  • Possible duplicate of [Django 1.11 TypeError context must be a dict rather than Context](https://stackoverflow.com/questions/43787700/django-1-11-typeerror-context-must-be-a-dict-rather-than-context) – Vitor Falcão Jun 11 '19 at 19:51
  • 2
    This code wouldn't give that error. You'd get it if you did `{'employeeId', employeeId}`, ie with a comma rather than a colon. – Daniel Roseman Jun 11 '19 at 20:16

0 Answers0