Как получить OTP только в админпанели django?
Я работаю над REST API и делаю проверку KYC по карте aadhar. Вот мой код:
admin.py
def save_model(self, request, obj, form, change):
customer_id = obj.customer_id
customer_object = Customer.objects.get(id=customer_id)
first_name = customer_object.first_name
middle_name = customer_object.middle_name
last_name = customer_object.last_name
customer_name = first_name + " " + last_name
date_of_birth = customer_object.date_of_birth
aadhar_card = obj.aadhar_card
# Send OTP request
url = AADHAR_AUTH_URL_OTP_SEND
header = {
"Content-Type":"application/json",
"x-karza-key" : KARZA_TOKEN
}
payload = {
"aadhaarNo": obj.aadhar_card,
"consent": "Y"
}
result = requests.post(url, data=json.dumps(payload), headers=header, verify=False)
result_json = result.json()
request_id = result_json.get('requestId', '')
# Verify OTP request
if request_id:
otp = input("Enter OTP received on registered mobile number: ") # ask the user to input the OTP
url = AADHAR_AUTH_URL_VERIFIED_OTP
payload = {
"aadhaarNo": obj.aadhar_card,
"consent": "Y",
"requestId": request_id,
"otp": otp
}
result = requests.post(url, data=json.dumps(payload), headers=header, verify=False)
result_json = result.json()
status = result_json.get('result', {}).get('message', '')
# Save the results to the database
if change:
obj = aadhar_card.objects.get(pk=obj.pk)
obj.aadhar_card = aadhar_card
obj.aadhar_request_json = json.dumps(payload)
obj.aadhar_response_json = json.dumps(result_json)
obj.updated_by = request.user.id
status_code = result_json.get('statusCode')
if status_code == 101:
obj.status = 101 # Verified
else:
obj.status = 3 # Not Verified
obj.save()
else:
obj.aadhar_card = aadhar_card
obj.aadhar_request_json = json.dumps(payload)
obj.aadhar_response_json = json.dumps(result_json)
obj.added_by = request.user.id
status_code = result_json.get('statusCode')
if status_code == 101:
obj.status = 101 # Verified
else:
obj.status = 3 # Not Verified
obj.save()
super().save_model(request, obj, form, change)
Теперь проблема в том, что я должен ввести OTP в терминале. Как я могу принять otp от пользователя на панели DJANGO ADMIN PANEL, поскольку я не использую никаких представлений, я работал только с admin.py.
Любая помощь будет принята с благодарностью!