Skip to content
Advertisement

Tag: django

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

DJango testing multiple database application

I have django application which has two database defaultdb and externdb The application works well but when testing ,this error occurs below when trying to access the extern database This error occurs which setting should I check?? Answer Change: to this: OR You can also add databases = “extern” to this: final version: This method is what it basically suggests

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

Serving file asyncronously with Django and uvicorn

I have a Django view that serves the content of a file. The Django application was running with WSGI until recently. This worked fine. Then I adapted my application to use ASGI running uvicorn. The file serving is now broken as it seems to loose the connection. How can I serve the file asynchronously with Django and uvicorn? Current view:

Django – how to access request body in a decorator?

I need to access the body of a request inside of a decorator, how can i do that? I’m calling the cache_page decorator from get in a class based view. In order to perform some logic, i need to access the URL of the request in the decorator. Here is my code: Edit: i tried to do that with @wraps

Celery jobs not running on heroku (python/django app)

I have a Django app setup with some scheduled tasks. The app is deployed on Heroku with Redis. The task runs if invoked synchronously in the console, or locally when I also have redis and celery running. However, the scheduled jobs are not running on Heroku. My task: celery.py: In Procfile: worker: celery -A my_app worker –beat -S django -l

Advertisement