Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Web Technology by (19.9k points)

I placed a prediction model code inside views.py of Django i need to pass input data from html page to views.py. How to feed csv file into Django views.py through html page.And that csv file further used for read with pandas to proceed for my prediction model in views.py

def read(request):

  f=request.FILES('filename')

  df=pd.read_csv('f')

page.html

<form action="{% url 'count' %}" method="post" enctype="multipart/formdata">

   <input type = "file" name = "filename" />{% csrf_token%}

   <input type="submit" value="FORECAST"/>

</form>

it shows an error 'MultiValueDict' object is not callable

1 Answer

0 votes
by (25.1k points)

Pass the input field parameter in square bracket as dictionary needs square bracket.

f=request.FILES['filename']

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...