47๐
res = request.GET['paymentid']
will raise a KeyError
if paymentid
is not in the GET data.
Your sample php code checks to see if paymentid
is in the POST data, and sets $payID
to โ otherwise:
$payID = isset($_POST['paymentid']) ? $_POST['paymentid'] : ''
The equivalent in python is to use the get()
method with a default argument:
payment_id = request.POST.get('payment_id', '')
while debugging, this is what I see in the
response.GET: <QueryDict: {}>
,request.POST: <QueryDict: {}>
It looks as if the problem is not accessing the POST data, but that there is no POST data. How are you are debugging? Are you using your browser, or is it the payment gateway accessing your page? It would be helpful if you shared your view.
Once you are managing to submit some post data to your page, it shouldnโt be too tricky to convert the sample php to python.
2๐
for class based views, try this:
class YourApiView(generics.ListAPIView):
"""
API endpoint
"""
def post(self, request, *args, **kwargs):
print("request data")
print(request.data)
- [Django]-How can I activate the unaccent extension on an already existing model
- [Django]-Django Aggregation โ Expression contains mixed types. You must set output_field
- [Django]-Python Django Gmail SMTP setup
- [Django]-Django โ Overriding the Model.create() method?
- [Django]-Django: Redirect logged in users from login page
- [Django]-How to remove all of the data in a table using Django