Coder Social home page Coder Social logo

panosl / django-currencies Goto Github PK

View Code? Open in Web Editor NEW
93.0 5.0 81.0 258 KB

django-currencies allows you to define different currencies, and includes template tags/filters to allow easy conversion between them.

Home Page: http://pypi.python.org/pypi/django-currencies

License: BSD 3-Clause "New" or "Revised" License

Python 97.75% HTML 2.25%
python currencies django

django-currencies's People

Contributors

asucrews avatar bashu avatar bmihelac avatar cxong avatar davej avatar dhendo avatar einarf avatar ipablo avatar jkinathan avatar kaelweb avatar lalatgithub avatar mythrinagaraju avatar noxan avatar panosl avatar pasevin avatar racitup avatar ronanboiteau avatar stelzzz avatar strycore avatar thomastu avatar ydaniv avatar zhangziang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

django-currencies's Issues

Not Compatible with Django 4

You recently added Django 4 support but it looks like not working on my end. I'm getting the following error after installations.
cannot import name 'ugettext_lazy' from 'django.utils.translation'

The error is from jsonfield package that django-currencies require. The solution for this problem can be to upgrade the jsonfield because a newer version is available!

set_currency view error

I had an error trying to change {{ CURRENCY }} and {{ CURRENCY_CODE }} template variables via post method.
Variables could not be changed unless I changed
request.POST.get('currency_code, None) and request.GET.get('currency_code', None)
to
request.POST.get('currency', None) and request.GET.get('currency', None).
Dunno if this is error determined by my local settings or general bug.

This is how the code should look like to make it work:

@never_cache
def set_currency(request):
    next, currency_code = (
        request.POST.get('next') or request.GET.get('next'),
        request.POST.get('currency', None) or
        request.GET.get('currency', None))
    if not _is_safe_url(next, [request.get_host()]):
        next = request.META.get('HTTP_REFERER')
        if not _is_safe_url(next, [request.get_host()]):
            next = '/'

    response = HttpResponseRedirect(next)
    if currency_code and Currency.active.filter(code=currency_code).exists():
        # Set cookie irrespective for page cache visibility
        response.set_cookie(SESSION_KEY, currency_code)
        if hasattr(request, 'session'):
            request.session[SESSION_KEY] = currency_code
    return response

Pypi version is still 0.10

Hi @panosl the pypi version is still 0.10 and not django 4 compatible. Will you kindly upload the last version 0.12 to pypi? thanks

if i can help in any way let me know

context_processor does not handle there being no default currency

Firstly, thank you very much for this app!

I have installed the app and ran initcurrencies and updatecurrencies.

I have already set the TEMPLATE_CONTEXT_PROCESSORS to include currencies.context_processors.currencies and my site broke as I had not set a default currency yet.

It would be good to at least raise a more specific error in the middle ware or add a setting for default currency code.

Either way, thanks for this!

Bump version

Looks like there's been a fair few commits since 0.4.0, bump the version? Appears the updatecurrencies command in 0.4.0 doesn't work on Django 1.10.

Please add a changelog

Thank you for this useful library.

I notice there's been a new release recently -- it would be valuable if I could read through the differences in the versions to help me through the upgrade process.

Additional migration generated when upgrading

After updating from version 0.4.0 to 0.9.0 python manage.py makemigrations generates new migration for this library in the site-packages directory.

migration file:

# Generated by Django 2.1.10 on 2019-07-05 02:12

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('currencies', '0004_code_primary'),
    ]

    operations = [
        migrations.AlterField(
            model_name='currency',
            name='factor',
            field=models.DecimalField(decimal_places=10, default=1.0, help_text='Specifies the currency rate ratio to the base currency.', max_digits=30, verbose_name='factor'),
        ),
        migrations.AlterField(
            model_name='currency',
            name='is_base',
            field=models.BooleanField(default=False, help_text='Make this the base currency against which rate factors are calculated.', verbose_name='base'),
        ),
    ]

Shouldn't this be in the library already?

Django version: 2.1.10

unable to import currencies

I am trying to import currencies into my database with the command: python manage.py currencies yahoo import=USD and I keep getting the error: ImportError: No module named 'openexchangerates'.

I know that the OpenExchangeRates are optional so why does it keep asking for it eventhough I use yahoo.

Note: I dont want to use the OpenExchangerRates because if i install it with pip I get a error in the code when running it (something with init)

Special currency symbols cause warning

When trying to add a new currency from the admin console, the inclusion of a special character (I'm assuming it's unicode) causes a warning to occur.

Specifically, I was trying to add the Indian Rupee with the following values:

  • Code: INR
  • Name: Indian Rupee
  • Symbol: ₹
  • Factor: 0.0161958
  • Active: true
  • Base: false
  • Default: false

The exact text of the error is as follows:
Warning at /admin/currencies/currency/add/
Incorrect string value: '\xE2\x82\xB9' for column 'symbol' at row 1

The problem also occurs for the following symbols:

  • Afghanistan Afghani (؋)
  • Bulgarian Lev (лв)
  • Cambodian Riel (៛)
  • Costa Rica Colon (₡)
  • Cuban Peso (₱)
  • Iranian Rial (﷼)
  • Israeli Shekel (₪)
  • Korean Won (₩)
  • Laos Kip (₭)
  • Macedonian Dinar (ден)
  • Mongolian Tughrik (₮)
  • Nepalese Rupee (₨)
  • Nigerian Naira (₦)
  • Ukranian Hryvnia (₴)
  • Vietnamese Dong (₫)

The problem does not occur for the following symbols:

  • Pound (£)
  • Euro (€)
  • Aruba Guilder (ƒ)
  • Chinese Yuan (¥)

Environment:

  • Python 2.7.6
  • Django 1.6.5
  • django-currencies 0.3.3 (from pip)

Publishing 0.10.2

Hi team, thank you for the great work. I am wondering whether there is a plan to publish 0.10.2? It seems that this version is already written but not yet published (e.g. to PyPi). Thank you in advanced!

PyPI Markup

The project's long_description has invalid markup which will not be rendered on PyPI. The following syntax errors were detected:
line 165: Warning: "raw" directive disabled.

pypi package

Any plans to update the pypi package? The current one is 2 years old. It would make this project much more accessible for most people.

Requirements update

Hi,

As the openexchange is needed, you need to install openexchangerates package (pip install openexchangerates).
Could you update the doc ?
Also, i try to import json file containing devices definition, but i have got this error :

python manage.py loaddata /usr/local/venv/local/lib/python2.7/site-packages/currencies/management/commands/currencies.json Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/usr/local/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line utility.execute() File "/usr/local/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 345, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv self.execute(*args, **cmd_options) File "/usr/local/venv/local/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute output = self.handle(*args, **options) File "/usr/local/venv/local/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 60, in handle self.loaddata(fixture_labels) File "/usr/local/venv/local/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 100, in loaddata self.load_label(fixture_label) File "/usr/local/venv/local/lib/python2.7/site-packages/django/core/management/commands/loaddata.py", line 152, in load_label for obj in objects: File "/usr/local/venv/local/lib/python2.7/site-packages/django/core/serializers/json.py", line 85, in Deserializer six.reraise(DeserializationError, DeserializationError(e), sys.exc_info()[2]) File "/usr/local/venv/local/lib/python2.7/site-packages/django/core/serializers/json.py", line 79, in Deserializer for obj in PythonDeserializer(objects, **options): File "/usr/local/venv/local/lib/python2.7/site-packages/django/core/serializers/python.py", line 96, in Deserializer Model = _get_model(d["model"]) django.core.serializers.base.DeserializationError: Problem installing fixture '/usr/local/venv/local/lib/python2.7/site-packages/currencies/management/commands/currencies.json': string indices must be integers

Update to PyPi

PyPi and git are diffrent. I saw it in the model. Should be updated at the PyPI.

from pypi
`from six import python_2_unicode_compatible
from django.db import models
from django.utils.translation import gettext_lazy as _
from jsonfield.fields import JSONField

from .managers import CurrencyManager
`
in gitub

`from six import python_2_unicode_compatible
from django.db import models
from django.utils.translation import gettext_lazy as _

from .managers import `

rounding field on Currency model

Hi!

I have a working implementation of a rounding field on Currency model that enable cofiguring the rounding rules for each currency.
It also includes a round() method on Currency that takes a value and retuns it rounded.

No tests for now, but just checking if this is something you'll be interested in adding to django-currencies.

Thanks!

Unique code causes conflict

When migrating to django-currencies 0.4.0, new entries for HKD and ZAR currency codes where included which causes duplication in the database. Old enties for HKD and ZAR were marked as is_active=False, but this doesn't solve the issue because code is not unique. Uggly solution is to use SQL to remove inactive entries but this should be address with Django migrations.

Read the Docs

I'm updating the readthedocs we have, with the currect content of our repo. We need to go over this.

Where is currencies.util.calculate_price?

Hi, I'm just upgrading dependencies in one of my project, I notice the function currencies.utils.calculate_price is gone, I depend on this to do some currency conversion in a backend process.

I have tracked the deletion up to this commit 39b785a from @bashu, and I notice there's now a currencies.utils.calculate is that the same function that just got renamed? The commit message isn't helpful at all, it doesn't explain the changes that were made.

Thanks for the help!

Maintain historic rate conversions

When keeping historic data it is necessary to keep the rate at which an operation was made so we don't do past conversions using current rates.

I normally handle this outside of the currencies app, but I lose the ability to use its convert util.

Remove 'requires' option from setup.py

When using pip to install the latest master from github, I encounter the following error:

(myvirtualenv) $ pip install -e "git+https://github.com/panosl/django-currencies.git@master#egg=currencies"
Obtaining currencies from git+https://github.com/panosl/django-currencies.git@master#egg=currencies
  Updating /home/user/virtualenvs/myvirtualenv/src/currencies clone (to master)
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/home/user/virtualenvs/myvirtualenv/src/currencies/setup.py", line 95, in <module>
        'Topic :: Internet :: WWW/HTTP :: Dynamic Content',
      File "/usr/local/lib/python3.6/distutils/core.py", line 108, in setup
        _setup_distribution = dist = klass(attrs)
      File "/home/user/virtualenvs/myvirtualenv/lib/python3.6/site-packages/setuptools/dist.py", line 320, in __init__
        _Distribution.__init__(self, attrs)
      File "/usr/local/lib/python3.6/distutils/dist.py", line 253, in __init__
        getattr(self.metadata, "set_" + key)(val)
      File "/usr/local/lib/python3.6/distutils/dist.py", line 1207, in set_requires
        distutils.versionpredicate.VersionPredicate(v)
      File "/usr/local/lib/python3.6/distutils/versionpredicate.py", line 114, in __init__
        raise ValueError("expected parenthesized list: %r" % paren)
    ValueError: expected parenthesized list: '-jsonfield (>=1.0.3)'
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /home/user/virtualenvs/myvirtualenv/src/currencies/

The exact issue appears to be the use of the requires option within setup(). Specifically, setuptools interprets the dash character within the package name django-jsonfield as an arithmetic operator (see v3n0m-Scanner/V3n0M-Scanner#47 (comment)).

Since distutils is no longer in use by this package, wouldn't it be safe to remove the requires option from setup()?

better OpenExchangeRates error reporting

Changing the base currency from USD to some other currency requires a paid account with OpenExchangeRates.

Currently the API returns an error that doesn't make this clear at first glance:

openexchangerates.OpenExchangeRatesClientException: 
403 Client Error: Forbidden for url: http://openexchangerates.org/
api/latest.json?app_id=xxxxxxxxxxxxxxx&base=GBP

Copying the request URL to another tab reveals the problem but this exception should be handled appropriately.

Fix decimal type in datetime.fromtimestamp

python ./manage.py updatecurrencies oxr
raise TypeError: 'decimal.Decimal' object cannot be interpreted as an integer
on file: \venv\lib\site-packages\currencies\management\commands_openexchangerates.py", line 84, in get_ratetimestamp
return datetime.fromtimestamp(self.rates["timestamp"])

I fix this by replacing self.rates["timestamp"] to float(self.rates["timestamp"])

AttributeError: 'NoneType' object has no attribute 'string'

Getting this error when i try to run ./manage.py currencies yahoo

File "currencies/management/commands/_yahoofinance.py", line 73, in get_bulkcurrencies
    jscript = soup.find('script', type='text/javascript', text=re_start).string

AttributeError: 'NoneType' object has no attribute 'string'

Django3 support

ImportError: cannot import name 'python_2_unicode_compatible'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.