Hello guys,
I'm Carl Collins from Cameroon. I'm working on this Django Project and I
got stuck . Need help.The first thing I would love to ask is about
performing SQL queries in Django use Django ORM. Presume I have something
like this:
connection = sqlite.connect('data.db')
cursor = connection.cursor()
query = "SELECT * FROM items"
result = cursor.execute(query)
properties = []
for row in result:
items.append({})
connection.close()
print(json.dumps({'properties': properties})
I would love Django to run this automatically i.e fetch some field from the
database each time a button is clicked and do a post request to an API
using the json returned as the body of the request
NB: The data in the database is populated using a django form and I would
love to use the same data to do a post request to an api. The API requires
that the post body be in json format like
{
"currency": "",
"customerName": "",
"description": "",
"email": "",
"expiryDate": "",
"id": {
"uuid": "",
"version": ""
},
"items": [
{
"itemId": "",
"particulars": "",
"quantity": x,
"subTotal": y,
"unitCost": z
},
{
"itemId": " ",
"particulars": " ",
"quantity": j,
"subTotal": k,
"unitCost": l
}
],
"langKey": "en",
"merchantReference": " ",
"orderDate": " ",
"phoneNumber": " ",
"receiptUrl": " ",
"totalAmount": n
}
Thanks in advance
Cheers
Carl
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CAEPm0bzdAqMqtXYR4vgjVR%3D_PzJ3RPdAzO19KLyszwbs_PrkvA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.