Skip to content

Commit

Permalink
Explicitly set id field to AutoField on Rate model (#716)
Browse files Browse the repository at this point in the history
* Explicitly set id field to AutoField on Rate model

* Downgrade asgiref for pypy3

* remove newline

* Changes to tox ini

* Description of changes in changelog

* Update docs/changes.rst

Co-authored-by: Benjamin Balder Bach <benjaoming@gmail.com>

* Update docs/changes.rst

Co-authored-by: Benjamin Balder Bach <benjaoming@gmail.com>

* Pre-commit changes

* Remove referral to non-existent 3.2 tag

---------

Co-authored-by: Benjamin Balder Bach <benjaoming@gmail.com>
  • Loading branch information
alexnorgaard and benjaoming committed Jun 19, 2023
1 parent a09580c commit f242c2d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions djmoney/contrib/exchange/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def clear_rates(self):


class Rate(models.Model):
id = models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")
currency = models.CharField(max_length=CURRENCY_CODE_MAX_LENGTH)
value = models.DecimalField(max_digits=20, decimal_places=6)
backend = models.ForeignKey(ExchangeBackend, on_delete=models.CASCADE, related_name="rates")
Expand Down
12 changes: 12 additions & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ Changelog

- TBC...

`3.2` - unreleased
-------------------

**Changed**

- Explicitly define ``id`` in ``djmoney.contrib.exchange.Rate`` model - This ensures that the database table will use ``AutoField``
even if ``DEFAULT_AUTO_FIELD`` is set to ``BigAutoField`` in the Django project's settings #716

**Fixed**

- Downgrade asgiref to 3.6 to work with pypy3

`3.1`_ - 2023-04-20
-------------------

Expand Down
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ deps =
django41: {[django]41}
django42: {[django]42}
django_main: {[django]main}
# https://github.com/django-money/django-money/pull/716#issuecomment-1592594627
pypy3: asgiref<=3.6
commands = py.test --ds=tests.settings_reversion --cov=./djmoney {posargs}
usedevelop = false

Expand Down

0 comments on commit f242c2d

Please sign in to comment.