Skip to content
Advertisement

How can i fetch my data from database to django template?

Whenever I run this,

Exception Value:
name ‘current_user’ is not defined; error is raised.

I am not getting where i am doing the mistake as I m new in django programming. Please help me fetch the data

JavaScript

Advertisement

Answer

It looks like you will be getting that problem from showproduct(request) because you don’t define current_user in that method before calling it.

to call this result = AffProduct.objects.filter(user_id=current_user.id) you need to define current_user = request.user beforehand

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement