Skip to main content

Django-SHOP integration with django-currencies

Project description

Django-SHOP integration with django-currencies


This module allows Django-SHOP implementations to integrate live currency feeds. This will allow you to offer your shop product prices in the user’s chosen currency.

The module is currently compatible with Django v1.10.7. This documentation assumes a working knowledge of Django and Django-SHOP.

Release History


Please let me know of you have any feature suggestions, or wish to implement any of the below:

  • Fix for the db initialisation warning below.
  • Tests.
  • Continuous build integration including compatibility testing with various python, Django and Django-SHOP versions.


Follow the Readme for django-currencies. Install this module through pip: pip install djangoshop-currencies.

The Django-SHOP Money system has been extended to use django-currencies as a currency conversion backend. To enable this functionality your currencies configuration must satisfy the following requirements:

  1. ISO4217Exponent and symbol populating using ./ currencies iso (This automatically imports the currencies set in the SHOP_CURRENCIES setting)
  2. Currency factors populating using ./ updatecurrencies yahoo (This also sets the base currency to SHOP_DEFAULT_CURRENCY)
  3. Some currencies set to active in the admin interface


The currencies database table must be initialised before any Django app can import the included money types. Unfortunately the ./ command will automatically import a lot of modules when they are configured in INSTALLED_APPS causing an error which prevents you from running ./ migrate, etc.

As a workaround before a permanent solution is found:

  1. Create a minimal settings file which will be used temporarily to allow the currencies table of your database to be populated. As an example, one is included here.
  2. Run python migrate --settings shop_currencies.min_settings (or use your minimal settings file)
  3. Satisfy requirements 1. & 2. above & append --settings <min_settings> to the commands
  4. Run python migrate
  5. Run python createsuperuser to create an admin user
  6. Satisfy requirement 3. above

Once created, I recommend dumping your base currency as a fixture for subsequent use when initialising databases:

python dumpdata --indent 2 --output fixtures/currency.json --pks 1 currencies.currency
python loaddata --settings shop_currencies.min_settings fixtures/currency.json


Replace the DefaultCartModifier with the provided CurrencyCartModifier in your shop settings:

    # provides the default cart lines

Use the Money conversion extension which provides the to(code) function as below. The additional base argument is used by the cart modifier.

from django.db import models
from currencies.utils import get_currency_code
from import MoneyField

class MyModel(models.Model):
    unit_price = MoneyField()

    def get_price(self, request, base=False):
        if base:
            return self.unit_price
            session_currency_code = get_currency_code(request)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for djangoshop-currencies, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size djangoshop-currencies-0.2.0.tar.gz (7.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page