timsavage / django-extras Goto Github PK
View Code? Open in Web Editor NEWExtensions for Django to solve common development situations not (or not yet) covered by the core Django framework.
License: BSD 3-Clause "New" or "Revised" License
Extensions for Django to solve common development situations not (or not yet) covered by the core Django framework.
License: BSD 3-Clause "New" or "Revised" License
I have the following field in my Django app model:
total_amount = models.MoneyField("total amount including GST", max_digits=9, decimal_places=2, default=0)
When I try and add data using this field, I get an "Invalid literal for Decimal: ''" error with the following traceback:
Environment:
Request Method: POST
Request URL: http://robs-tosh-t130:8000/admin/accounts/account/add/
Django Version: 1.5
Python Version: 2.7.4
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.admindocs',
'django_extras',
'accounts')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
Traceback:
File "/dev/simple-bas/simple_bas/eggs/Django-1.5-py2.7.egg/django/core/handlers/base.py" in get_response
115. response = callback(request, *callback_args, **callback_kwargs)
File "/dev/simple-bas/simple_bas/eggs/Django-1.5-py2.7.egg/django/contrib/admin/options.py" in wrapper
372. return self.admin_site.admin_view(view)(*args, **kwargs)
File "/dev/simple-bas/simple_bas/eggs/Django-1.5-py2.7.egg/django/utils/decorators.py" in _wrapped_view
91. response = view_func(request, *args, **kwargs)
File "/dev/simple-bas/simple_bas/eggs/Django-1.5-py2.7.egg/django/views/decorators/cache.py" in _wrapped_view_func
89. response = view_func(request, *args, **kwargs)
File "/dev/simple-bas/simple_bas/eggs/Django-1.5-py2.7.egg/django/contrib/admin/sites.py" in inner
202. return view(request, *args, **kwargs)
File "/dev/simple-bas/simple_bas/eggs/Django-1.5-py2.7.egg/django/utils/decorators.py" in _wrapper
25. return bound_func(*args, **kwargs)
File "/dev/simple-bas/simple_bas/eggs/Django-1.5-py2.7.egg/django/utils/decorators.py" in _wrapped_view
91. response = view_func(request, *args, **kwargs)
File "/dev/simple-bas/simple_bas/eggs/Django-1.5-py2.7.egg/django/utils/decorators.py" in bound_func
21. return func(self, *args2, **kwargs2)
File "/dev/simple-bas/simple_bas/eggs/Django-1.5-py2.7.egg/django/db/transaction.py" in inner
223. return func(*args, **kwargs)
File "/dev/simple-bas/simple_bas/eggs/Django-1.5-py2.7.egg/django/contrib/admin/options.py" in add_view
989. if form.is_valid():
File "/dev/simple-bas/simple_bas/eggs/Django-1.5-py2.7.egg/django/forms/forms.py" in is_valid
126. return self.is_bound and not bool(self.errors)
File "/dev/simple-bas/simple_bas/eggs/Django-1.5-py2.7.egg/django/forms/forms.py" in _get_errors
117. self.full_clean()
File "/dev/simple-bas/simple_bas/eggs/Django-1.5-py2.7.egg/django/forms/forms.py" in full_clean
274. self._post_clean()
File "/dev/simple-bas/simple_bas/eggs/Django-1.5-py2.7.egg/django/forms/models.py" in _post_clean
332. self.instance.clean_fields(exclude=exclude)
File "/dev/simple-bas/simple_bas/eggs/Django-1.5-py2.7.egg/django/db/models/base.py" in clean_fields
946. setattr(self, f.attname, f.clean(raw_value, self))
File "/dev/simple-bas/simple_bas/eggs/Django-1.5-py2.7.egg/django/db/models/fields/__init__.py" in clean
212. self.validate(value, model_instance)
File "/dev/simple-bas/simple_bas/eggs/Django-1.5-py2.7.egg/django/db/models/fields/__init__.py" in validate
202. if not self.blank and value in validators.EMPTY_VALUES:
File "/dev/simple-bas/simple_bas/eggs/django_extras-0.2.8-py2.7.egg/django_extras/core/types.py" in __eq__
133. return self._amount == decimal.Decimal(str(other))
File "/usr/lib/python2.7/decimal.py" in __new__
548. "Invalid literal for Decimal: %r" % value)
File "/usr/lib/python2.7/decimal.py" in _raise_error
3872. raise error(explanation)
Exception Type: InvalidOperation at /admin/accounts/account/add/
Exception Value: Invalid literal for Decimal: ''
As far as I can tell, the code is trying to validate my data (which was 120.00) against an empty string (?) in validators.EMPTY_VALUES and failing because that's not a Decimal.
I have the following field in my Django app model:
total_amount = models.MoneyField("total amount including GST", max_digits=9, decimal_places=2, default=0)
When I add a new record via the web interface, valid data entered into this field is not persisted to the database (PostgreSQL in my case).
After adding a record and checking the DB (using the pgAdmin III tool), I then updated my total_amount field via this tool and saved it. After this, when I edited that record via the Django Admin web interface, the value I put directly into the DB was displayed in my total_amount field on the web edit form. However, when I saved this web form without making any changes to the data, my MoneyField data was again wiped from the database record.
It seems that a null value is being consistently written to the database when a MoneyField value is being saved.
The current method of executing Django tests is not finding any tests under Django 1.6
Many test cases failing
This may involve deprecating older versions of Django that do not support Python 3.
Investigate available options to support this.
A large number of test cases are failing.
Many test cases failing
What are the installation/usage instructions?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.