in the below code my problem is , when word (which s given by user) is searched when is not in the my table column, pop up message appears and says user doesn't exist , but my if searched is not working, does any body have an idea where i'm doing it wrong, please let me know , i'm working in django, pandas
def products(request):
if request.method == "POST":
df = pd.read_csv("media_cdn/media/user_change_history.csv",header=None)
searched = request.POST\['searched'\]
context = {}
if searched in df.index:
data = df.loc\[df\[0\] == searched\]
\#if data in df.index:
data = data.transpose()
data = data.to_html(classes='table-wrapper')
context = {'d': data}
else:
messages.info(request, 'Username is incorrect')
return render(request, 'blog/products.html', context)
else:
return render(request, 'blog/products.html')
in the above code my problem is , when word (should represent a cell in user ID column) (which s given by user) is searched when is not in the my table column, pop up message appears and says user doesn't exist , but my if searched is not working, does any body have an idea where i'm doing it wrong, please let me know , i'm working in Django, pandas