I cannot see the database data in the Django-Rest-framework api

Asked

Viewed 37 times

0

I’m trying to set up a chess board with Django Rest Framework, so I want only the positions to be loaded, but I always get returned only "None". This is because the last database records are actually "None", but my problem is that it is loading only the last value in the api, and not the data respectively. Thank you very much, from now on!

Models py.:

class Board(models.Model):
    chess_board = [['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'], ['1', '2', '3', '4', '5', '6', '7', '8']]
    c.execute('SELECT * FROM piecesapp_board')
    con.commit()
    id =  models.AutoField(primary_key=True)
    position_y = ''
    position_x = ''
    piece = 'sda'
    for i in c:   
        position_y = str(i[1])
        position_x = str(i[2])
        piece = str(i[3])

My database(Sqlite3):

enter image description here

Upshot:

enter image description here

  • Welcome to Stack Overflow in English. I edited your question to remove the greetings as we usually keep the text as clean as possible to focus on your scheduling question. If you are interested in visiting a part of the site that is not aimed to ask questions can know the [chat]. If you have questions about the operation, rules and procedures of the site visit the [meta] :)

  • Some reason you are doing SQL manually instead of using Django’s ORM?

  • Images are not loading correctly

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.