Answer the question
In order to leave comments, you need to log in
How to turn a Queryset into a string?
I have in myurl = Answer.objects.all()
(Answer is a class with one parameter
url_csv = model.Charfield('File link', max_length = 200) )
The user must fill in the link and the program should read and process through my_data = pd. read_csv(myurl) and of course pd.read_csv does not accept a queryset, but it does accept a string. What should I do to turn the queryset into a string, or is there some other way to solve the problem? I'm new so I can be stupid in the comments, SORRY (
Answer the question
In order to leave comments, you need to log in
Take the required element from the QuerySet, take its url_csv field and load the data
It is better, of course, not to get all the objects, but only the one you need, for example, through pk
Well, do not call the myurl variable. There are no urls in it - it contains a QuerySet of objects, mislead yourself
Well, let's say we get all the objects from which we need the last one
answer_object = Answers.objects.get(pk=1)
last_answer = Answers.objects.all().last()
if last_answer:
my_data = pd.read_csv(last_answer.url_csv)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question