Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get all table data in Django

Tags:

python

django

I'm trying to access into a Database data through a Django view. The problem is that when I query it, it just returns me the result of the unicode function on the model. How can I access to the other fields of the model?

Thanks!

like image 634
Paolo Avatar asked Aug 20 '13 16:08

Paolo


1 Answers

say you have a student database,

student_list = Student.objects.all()
for student in student_list:
    print student.name

The other fields can be used in the iterator, using the dot(.) operator

like image 104
Aswin Murugesh Avatar answered Oct 14 '22 07:10

Aswin Murugesh