Skip to content
Advertisement

Tag: django-rest-framework

How To give optional parameter in DRF

Hi Everyone i am created one api, where i will use [city] as first parameter to get result based on city, but i need [id] also as second parameter but [id] is optional, same time we use [id] as second parameter and sometime not, please help me out for ex- 1-get data based on city url=127.0.0.1:8000/api/car/city 2-get data based on

how to create row in model based on data fetched from JSON request from third-party crawling with “best practice”

describe the problem: I want to crawl data from dataforseo , and save them directly in model database through model.create() method with having multi model with multi relation with models so for instance in model A have ManyToMany relation with model B ManyToMany relation with model C ManyToMany relation with model D and model B have relation with model C

Python: Run a code after return something

This is an ApiView from my django project: As you see, if client.is_busy is not True, I’m making it True in here. But in this situation, I need to client.is_busy = False after 30 seconds. If I do it under client.save() code, it delays to response. How can I do it? Answer You should consider using timer objects here. e.g.

Advertisement