Skip to main content

Django-SHOP integration with django-currencies

Introduction

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

TODO

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.

Configuration

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 ./manage.py currencies iso (This automatically imports the currencies set in the SHOP_CURRENCIES setting)

  2. Currency factors populating using ./manage.py updatecurrencies yahoo (This also sets the base currency to SHOP_DEFAULT_CURRENCY)

  3. Some currencies set to active in the admin interface

Usage

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

SHOP_CART_MODIFIERS = (
    # provides the default cart lines
    'shop_currencies.modifiers.CurrencyCartModifier',
    ...

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 shop_currencies.money.fields import MoneyField

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

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

Release files for djangoshop-currencies 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for djangoshop-currencies 0.2.0
File Size Uploaded
djangoshop-currencies-0.2.0.tar.gz 7.0 kB Details

Release files / djangoshop-currencies-0.2.0.tar.gz

Download URL djangoshop-currencies-0.2.0.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
fa8cc4dd225532a0d7de92e11b5525fea0e224601753edc8ad989b88ae1d2cd1
BLAKE2b-256 checksum
How to use checksums
adcfb64e68f752e27657ea56601dd9731b94f77002790ede668b12f3143d93f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2.0 This release

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page