I want to convert currencies in my Django app. I created a model Customer. In customer model, there are two fields for that credit_limit and currency_choice. I am using django-money for conversion. But I get an error: MissingRate at /customer Rate GBP -> USD does not exist How can I solve it? views.py: models.py: settings.py: traceback: Answer I took a
Tag: django
django.db.utils.OperationalError: no such function: JSON_VALID
I literally don’t know how to deal with it and how it is happening I am getting this error when I run python manage.py migrate, migrations were without an error. Mycode models.py views.py full command line error If you are able to solve the issue then answer and along with it also tell me any issue in my code or
Why django dependent dropdownn is not working
I cant tell where there is an error in my code. It just doesnt work as expected. My views.py My models. My forms.py I have tried but it works only after I select a year and refresh manually with the year selcted, that’s when the terms appear. I tried following the code by Vitor Freitas but couldn’t get it working.
How to return related objects a queryset’s values_list instead of just the PKs
Is there a way to neatly return a queryset’s values_list of related objects from many objects’ related managers at the same time without having to write a loop ? In other words this query: will return me a list of PKs that will look something like this: Is it possible to write such query that will return the actual objects
Update a field of a Django Object
I’m trying to update an object field in django. Usually I would do something like this: The problem is that the field to modify (in the example above: “name”) is not known and passed as an argument to the post request. So I would have something like this: now this triggers the error: What is the correct way to update
How should I improve my styling here (python class, Django models)?
My main model class looks like this: And, for my api to send backend data to front end, I have a serializers class that looks like this: Clearly, the current way of writing fields as a bunch of hard-coded strings is very clumsy and prone to mistake (since I might change the fields in Article class but forget to update
How to get the most liked users in django rest-api
So I have a social media app, where users can like the posts of other users. Now I want to fetch the top 20 users who have received the most number of likes. I am pretty much confused how to query my Likes Model My LIKES MODEL SIMPLIFIED POST MODEL SIMPLIFIED USER MODEL ** My View ** Answer First I
How can pass primary key to url Django
I have basically 3 issues I am trying to pass the primary key of vendor in url after creating it, but when i go the vendor page it shows the error ‘ Reverse for ‘vendorCategory’ with arguments ‘(”,)’ not found. 1 pattern(s) tried: [‘vendorCategory/(?P<vendor_id>[0-9]+)/$’] ‘ In Vendor Category when i am trying to store multiple products against the specific vendor
converting a Django ValuesListQuerySet object to a float
i have time data saved (in epoch time) in a MySQL database as a IntegerField. i’m doing some data visualisation where i’d like to show orders by the hour and by day of the week as bar charts, so i’d like to convert these epoch times to date time objects and visualise the data accordingly. however, datetime.datetime.fromtimestamp() only takes in
Obtaining full requested url address
I’m looking to obtain the full requested url within python/django. I’m wondering what package might help me do this. For example, if someone goes to example.com/my-homepage, I want to capture the string ‘example.com/my-homepage’ in python. Thanks! Answer