shop order error

4 views
Skip to first unread message

aleray

unread,
Sep 23, 2008, 9:15:10 AM9/23/08
to Satchmo users
Hi,

I have been trying to place a shop order "manually" from the admin
interface and I'm getting an error :

IntegrityError at /admin/shop/order/add/
shop_order.site_id may not be NULL

So I took a look satchmo.shop.admin and changed :

class OrderOptions(admin.ModelAdmin):
fieldsets = (
(None, {'fields': ('contact', 'method', 'status',
'discount_code', 'notes')}), (_('Shipping Method'), {'fields':


to :

class OrderOptions(admin.ModelAdmin):
fieldsets = (
(None, {'fields': ('site', 'contact', 'method', 'status',
'discount_code', 'notes')}), (_('Shipping Method'), {'fields':


Then the order is add to the (sqlite3) database but I get a
TemplateSyntaxError at /admin/shop/order/ . Here is the log:

Environment:

Request Method: GET
Request URL: http://127.0.0.1:8000/admin/shop/order/
Django Version: 1.0-final-SVN-unknown
Python Version: 2.5.0
Installed Applications:
['django.contrib.admin',
'django.contrib.admindocs',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.comments',
'comment_utils',
'django.contrib.sitemaps',
'satchmo.caching',
'satchmo.configuration',
'satchmo.shop',
'satchmo.contact',
'satchmo.product',
'satchmo.shipping',
'satchmo.payment',
'satchmo.discount',
'satchmo.giftcertificate',
'satchmo.supplier',
'satchmo.thumbnail',
'satchmo.l10n',
'satchmo.tax',
'satchmo.recentlist',
'satchmo.productratings']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.locale.LocaleMiddleware',
'satchmo.shop.SSLMiddleware.SSLRedirect',
'satchmo.recentlist.middleware.RecentProductMiddleware')


Template error:
In template /Volumes/STOCK/Users/aleray/lib/Django-1.0/django/contrib/
admin/templates/admin/change_list.html, error at line 34
Caught an exception while rendering: Cannot convert None to Decimal
24 : {% if cl.has_filters %}
25 : <div id="changelist-filter">
26 : <h2>{% trans 'Filter' %}</h2>
27 : {% for spec in cl.filter_specs %}
28 : {% admin_list_filter cl spec %}
29 : {% endfor %}
30 : </div>
31 : {% endif %}
32 : {% endblock %}
33 :
34 : {% block result_list %} {% result_list cl %} {% endblock %}
35 : {% block pagination %}{% pagination cl %}{% endblock %}
36 : </div>
37 : </div>
38 : {% endblock %}
39 :

Traceback:
File "/Volumes/STOCK/Users/aleray/lib/Django-1.0/django/core/handlers/
base.py" in get_response
86. response = callback(request, *callback_args,
**callback_kwargs)
File "/Volumes/STOCK/Users/aleray/lib/Django-1.0/django/contrib/admin/
sites.py" in root
158. return self.model_page(request, *url.split('/',
2))
File "/Volumes/STOCK/Users/aleray/lib/Django-1.0/django/views/
decorators/cache.py" in _wrapped_view_func
44. response = view_func(request, *args, **kwargs)
File "/Volumes/STOCK/Users/aleray/lib/Django-1.0/django/contrib/admin/
sites.py" in model_page
177. return admin_obj(request, rest_of_url)
File "/Volumes/STOCK/Users/aleray/lib/Django-1.0/django/contrib/admin/
options.py" in __call__
189. return self.changelist_view(request)
File "/Volumes/STOCK/Users/aleray/lib/Django-1.0/django/contrib/admin/
options.py" in changelist_view
662. ], context,
context_instance=template.RequestContext(request))
File "/Volumes/STOCK/Users/aleray/lib/Django-1.0/django/shortcuts/
__init__.py" in render_to_response
18. return HttpResponse(loader.render_to_string(*args,
**kwargs), **httpresponse_kwargs)
File "/Volumes/STOCK/Users/aleray/lib/Django-1.0/django/template/
loader.py" in render_to_string
107. return t.render(context_instance)
File "/Volumes/STOCK/Users/aleray/lib/Django-1.0/django/template/
__init__.py" in render
176. return self.nodelist.render(context)
File "/Volumes/STOCK/Users/aleray/lib/Django-1.0/django/template/
__init__.py" in render
768. bits.append(self.render_node(node, context))
File "/Volumes/STOCK/Users/aleray/lib/Django-1.0/django/template/
debug.py" in render_node
71. result = node.render(context)
File "/Volumes/STOCK/Users/aleray/lib/Django-1.0/django/template/
loader_tags.py" in render
97. return compiled_parent.render(context)
File "/Volumes/STOCK/Users/aleray/lib/Django-1.0/django/template/
__init__.py" in render
176. return self.nodelist.render(context)
File "/Volumes/STOCK/Users/aleray/lib/Django-1.0/django/template/
__init__.py" in render
768. bits.append(self.render_node(node, context))
File "/Volumes/STOCK/Users/aleray/lib/Django-1.0/django/template/
debug.py" in render_node
71. result = node.render(context)
File "/Volumes/STOCK/Users/aleray/lib/Django-1.0/django/template/
loader_tags.py" in render
97. return compiled_parent.render(context)
File "/Volumes/STOCK/Users/aleray/lib/Django-1.0/django/template/
__init__.py" in render
176. return self.nodelist.render(context)
File "/Volumes/STOCK/Users/aleray/lib/Django-1.0/django/template/
__init__.py" in render
768. bits.append(self.render_node(node, context))
File "/Volumes/STOCK/Users/aleray/lib/Django-1.0/django/template/
debug.py" in render_node
71. result = node.render(context)
File "/Volumes/STOCK/Users/aleray/lib/Django-1.0/django/template/
loader_tags.py" in render
24. result = self.nodelist.render(context)
File "/Volumes/STOCK/Users/aleray/lib/Django-1.0/django/template/
__init__.py" in render
768. bits.append(self.render_node(node, context))
File "/Volumes/STOCK/Users/aleray/lib/Django-1.0/django/template/
debug.py" in render_node
71. result = node.render(context)
File "/Volumes/STOCK/Users/aleray/lib/Django-1.0/django/template/
loader_tags.py" in render
24. result = self.nodelist.render(context)
File "/Volumes/STOCK/Users/aleray/lib/Django-1.0/django/template/
__init__.py" in render
768. bits.append(self.render_node(node, context))
File "/Volumes/STOCK/Users/aleray/lib/Django-1.0/django/template/
debug.py" in render_node
81. raise wrapped

Exception Type: TemplateSyntaxError at /admin/shop/order/
Exception Value: Caught an exception while rendering: Cannot convert
None to Decimal

Original Traceback (most recent call last):
File "/Volumes/STOCK/Users/aleray/lib/Django-1.0/django/template/
debug.py", line 71, in render_node
result = node.render(context)
File "/Volumes/STOCK/Users/aleray/lib/Django-1.0/django/template/
__init__.py", line 915, in render
dict = func(*args)
File "/Volumes/STOCK/Users/aleray/lib/Django-1.0/django/contrib/
admin/templatetags/admin_list.py", line 242, in result_list
'results': list(results(cl))}
File "/Volumes/STOCK/Users/aleray/lib/Django-1.0/django/contrib/
admin/templatetags/admin_list.py", line 237, in results
yield list(items_for_result(cl,res))
File "/Volumes/STOCK/Users/aleray/lib/Django-1.0/django/contrib/
admin/templatetags/admin_list.py", line 159, in items_for_result
attr = getattr(result, field_name)
File "/Volumes/STOCK/Users/aleray/lib/satchmo-1545/satchmo/shop/
models.py", line 809, in _order_total
return moneyfmt(self.total)
File "/Volumes/STOCK/Users/aleray/lib/satchmo-1545/satchmo/l10n/
utils.py", line 126, in moneyfmt
val = trunc_decimal(val, places)
File "/Volumes/STOCK/Users/aleray/lib/satchmo-1545/satchmo/utils/
__init__.py", line 133, in trunc_decimal
val = Decimal(val)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/decimal.py", line 617, in __new__
raise TypeError("Cannot convert %r to Decimal" % value)
TypeError: Cannot convert None to Decimal

First, is it necesseary to change the satchmom/shop/admin.py file? and
then any idea on what append and how to fix this?

Thanks

Bruce Kroeze

unread,
Sep 23, 2008, 11:50:27 AM9/23/08
to satchm...@googlegroups.com
On Tue, Sep 23, 2008 at 6:15 AM, aleray <alex...@alexandreleray.com> wrote:

Hi,

I have been trying to place a shop order "manually" from the admin
interface and I'm getting an error :

IntegrityError at /admin/shop/order/add/
shop_order.site_id may not be NULL

Added 'site' to admin in [1551] and fixed subsequent errors from null values during total calculation.

aleray

unread,
Sep 23, 2008, 2:58:07 PM9/23/08
to Satchmo users
Very nice!

On Sep 23, 5:50 pm, "Bruce Kroeze" <bkro...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages