Hi i am trying to import the csv file data into database my views.py def Filter(request): if request.method=="POST": form = DataForm(request.POST, request.FILES) if form.is_valid(): initial_obj = form.save(commit=False) data=initial_obj['data'] path="C:\\Users\\ramma\\Downloads\\assesment.csv" os.chdir(path)
with open('assesment.csv') as csvfile: reader = csv.DictReader(csvfile) for row in reader: file=data(name=row['product'],) initial_obj.save() file.save() return redirect('/') else: return render(request,'index.html',{'form':form}) else: return render(request,'index.html',{'form':form}) def search(request): list = data.objects.all() data_filter = DataFilter(request.GET, queryset=list) return render(request, 'product.html', {'filter': data_filter}) -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CALJzFiqOMj5Lz2MZKvrPbB%3DXFfOrdBFeSBjd53tO7eVY9NDy5w%40mail.gmail.com.