'how to add data to database in django

I send the data I get from websocket with javascript to the view.py section of python-django with var xhr = new XMLHttpRequest() ///. my question is; The data comes to view.py. How can I save this incoming data to the database from now on?

views.py;

def gelismis_alim(request):
    data = json.loads(request.body)
    front_end_adet = data.get('adet')

    //I know probably,I should write here something to add it to database but I don't know what it is.
    
    print(data) 
    return HttpResponse('/')enter code here

the data which sended with js to django, stored in front_end_adet variable.this data is static, not change everytime. When I take a data from websocket I store it in a variable then I send it django view for once.

my model.py;

class AL(models.Model):
    quant = models.CharField(null=False)
    price = models.CharField(null=False)

class SAT(models.Model):
    quant = models.CharField(null=False)
    price = models.CharField(null=False)enter code here

What I want is to add the data in the front_end_piece variable to the quant part of the AL table.I would be glad if you help thank you.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source