Django: How to get tax amount for diffrent countries and multiply it by product price in django?

I am creating an ecommerce system where i would need to calculate taxes for diffrent countries during checkout. I have added a flat rate for the tax, but that is not how tax works, it need to be percentage based which i have done, but how do i know the country a user is about to order a product from and also get the tax amount for that country and do my basic calculation.

please if you have done this before i would really appreciate any help as that would help me fix this issue.

Right now, this is how i am performing the tax calculation with a fixed percentage for all users from all countries

def cart(request):
     new_tax_amount = 0
     tax_amount_by_percentage = 25 / 100 # 25% / 100 = 0.25
     new_tax_amount += int(item['qty']) * float(tax_amount_by_percentage )

This works well for me, but i need to know how to get tax percentage based on the country the user is trying to order the product from, then do my

hi,

if you will have multiple stores in you site, i would use the store country. otherwise i would ask the user for the country at some point in the registration.

i wouldnt do it dynamically, for example by using the users ip addr, because they can, for example, use a proxy or vpn

how about if i want to use the user’s country? and also i have a guest checkout feature, where a user don’t have to signup to make an order, how do i get thier country in that scenario? should i get it from when they fill out thier shipping address.

thanks for this, i was already trying to do this using thier ip addr

we have a similar feature, but there are lot of problem using the user country, what we did and the end, was ask the user for the address and use that address for taxes because in our case anyway we need to ship some