1๐
โ
.watch_list
is a manager, not a QuerySet
, and thus not iterable, you convert this into a QuerySet
with .all()
[Django-doc], you should also work with request.user
, not User
, since User
is a class, not the user:
def watchlist(request):
watchlist_list = request.user.watchlist.all()
context = {
'watchlist_list': watchlist_list
}
# โฆ
Note: It is normally better to make use of the
settings.AUTH_USER_MODEL
[Django-doc] to refer to the user model, than to use theUser
model [Django-doc] directly. For more information you can see the referencing theUser
model section of the documentation.
Source:stackexchange.com