Search code examples
pythondjango

How to print a model object properly in Django?


I am new in django, I want to print my data, i am using this function to get data from table, page_data = Pages.objects.all().filter(id=id), i am getting this response <QuerySet [<Pages: Page 567>]>, why it shows only title column data ? It should show all the data, can anyone plese help me to show all the data whitin the table with print in cmd ?

enter image description here


Solution

  • You can see each property data by accessing using the property name like

    page_data.id 
    page_data.title
    

    By default the the query set will display only the primary key of the record as a tag for the query set which is why you see the id value 567 in [<Pages: Page 567>]