rest

Is there a way to add custom data into ListAPIView in django rest framework

Is there a way to add custom data into ListAPIView in django rest framework Question: So I’ve built an API for movies dataset which contain following structure: Models.py class Directors(models.Model): id = models.IntegerField(primary_key=True) first_name = models.CharField(max_length=100, blank=True, null=True) last_name = models.CharField(max_length=100, blank=True, null=True) class Meta: db_table = ‘directors’ ordering = [‘-id’] class Movies(models.Model): id = …

Total answers: 3

How can I handle 400 bad request error using DRF in Django

How can I handle 400 bad request error using DRF in Django Question: I am trying to perform a POST request using DRF in Django, the program is raising a 400 error (this is the error, Bad Request: /api/menu_items/, the frontend is raising the following error (This field is required) the problem is I cannot …

Total answers: 1

How to define multiple API endpoints in FastAPI with different paths but the same path parameter?

How to define multiple API endpoints in FastAPI with different paths but the same path parameter? Question: I’m working on a project which uses FastAPI. My router file looks like the following: # GET API Endpoint 1 @router.get("/project/{project_id}/{employee_id}") async def method_one( project_id: str, organization_id: str, session: AsyncSession = Depends(get_db) ): try: return await CustomController.method_one( session, …

Total answers: 1

Django Error: 'DetailView' object has no attribute '_meta'

Django Error: 'DetailView' object has no attribute '_meta' Question: This has floored me. I’m building a model with Django & REST API, and I’m having trouble rendering the DetailView for individual cars to the browser. The ListView works fine, but I’ll include the code too since they are interlinked. In particular, I can’t get the …

Total answers: 1

an error in sending json data to flask server

an error in sending json data to flask server Question: I have a json data as {"age":59.0,"bp":70.0,"sg":1.01,"al":3.0,"su":0.0,"rbc":1.0,"ba":0.0,"bgr":76.0,"bu":186.0,"sc":15.0,"sod":135.0,"pot":7.6,"hemo":7.1,"pcv":22.0,"wbcc":3800.0,"rbcc":2.1,"htn":1.0,"dm":0.0,"cad":0.0,"appet":0.0,"pe":1.0,"ane":1.0} I have to send this json into a ML model that is inside a flask server to predict outcome class as 0 or 1. so for that I wrote the following code in app.py # flask route for …

Total answers: 1

Time zone offset change history dataset by date and city parameter

Time zone offset change history dataset by date and city parameter Question: I am searching for Rest API that will allow me to get all Time zone offset changes of city between dates. Is there any API like this (not free) ? For example: Get –> Headers: City From date To date Rome 2001-01-01 00:00:01.000 …

Total answers: 1

Unable to send sms on whatapp throguht route

Unable to send sms on whatapp throguht route Question: bascially i am making a route in which i have connect my api of whatapp when i send a number in my json response thought software this route should send me a whatapp message on that number @app.route(‘/v1.1/userRegistor’, methods=[‘POST’,’GET’]) def get_user(): data = request.get_json() numbers=data[‘numbers’] api_url …

Total answers: 1

REST related/nested objects URL standard

REST related/nested objects URL standard Question: if /wallet returns a list a wallets and each wallet has a list of transactions. What is the standard OpenAPI/REST standard? For example, http://localhost:8000/api/wallets/ gives me { "count": 1, "next": null, "previous": null, "results": [ { "user": 1, "address": "3E8ociqZa9mZUSwGdSmAEMAoAxBK3FNDcd", "balance": "2627199.00000000" } ] } http://localhost:8000/api/wallets/3E8ociqZa9mZUSwGdSmAEMAoAxBK3FNDcd/ gives me { …

Total answers: 1

converting Flask message received in in "text/plain" format to JSON format

converting Flask message received in in "text/plain" format to JSON format Question: I have an issue with FLASK that I am hoping to resolve. I am sending this type of input to a Flask server: [ "tradeid": "5L5A0", "message": "", "accountid": 20, "ticker": {{ticker}}, "currentprice": {{close}}, "action": "X_OPEN" ] I have also tried (changing ] …

Total answers: 1

How to conver unicode codes into normal text?

How to conver unicode codes into normal text? Question: A REST API returns some text in this form: "text": "u0422u044eu043bu044eu043bu044eu043c-u0422u044eu043bu044eu043bu044eu043c" I know what language the original text in. How to convert it into the normal form? Asked By: duman || Source Answers: So I encoded the text first using the encode function. This would return …

Total answers: 1