I have a user form through which I can save data to the database. I want certain fields to be auto calculated while I am filling the the form. For e.g. Net Weight = Gross Weight – Tier Weight and stuff like that. I also want to add RADIO BUTTONS for fields like LOADING, UNLOADING, DEDUCTION, etc. where values will
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
How can I get top 5 inventory items from a django model which has lowest quantity?
#This is my inventory model. I want to get the inventory items that have the lowest quantity in the model. Answer To get a number of results with the lowest or highest value you first order by that field order_by(‘quantity’) so that the results you want will be first, then you can slice the queryset to limit the number of
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
List products in relation to the vendor clicked in django ecommerce
I have listed all the vendors (users which are staff) in my django tempelate using the following code. In tempelates: In views: The usernames of the suppliers(vendors) is already listed. What I want is the products of the respective vendor will be dispalyed in a separate html page when the vendor username is clicked. Now the above code is displaying
Can’t get form class object in template view
I want to get the form object from self.Form This is my form and I set form as form_class, however I can’t fetch the form data in view I think this is the simplest set, but how can I make it work? Answer Try this: