Tag Archives: satchmo

Satchmo/Django: “ProgrammingError: can’t adapt type ‘__proxy__'”

I got the above error when laoding a shipping module in Satchmo, but upon working out the cause, I reckoned it must be a pretty common error these days.

The exception is raised in /django/db/backends/util.py, line 19.
When I checked the local vars of the query.py step, line 2369, I got the following SQL:
[sourcecode language=’sql’]
‘UPDATE “shop_order” SET “site_id” = %s, “contact_id” = %s, “ship_addressee” = %s, “ship_street1” = %s, “ship_street2” = %s, “ship_city” = %s, “ship_state” = %s, “ship_postal_code” = %s, “ship_country” = %s, “bill_addressee” = %s, “bill_street1” = %s, “bill_street2” = %s, “bill_city” = %s, “bill_state” = %s, “bill_postal_code” = %s, “bill_country” = %s, “notes” = NULL, “sub_total” = %s, “total” = %s, “discount_code” = %s, “discount” = %s, “method” = %s, “shipping_description” = %s, “shipping_method” = %s, “shipping_model” = %s, “shipping_cost” = %s, “shipping_discount” = %s, “tax” = %s, “time_stamp” = %s, “status” = %s WHERE “shop_order”.”id” = %s
with the following params:
(1, 761, u’abc abc’, u’abc’, u’abcabc’, u’abc’, u'(UK32)’, u’E17 8QG’, u’GB’, u’abc abc’, u’abc’, u’abcabc’, u’abc’, u'(UK32)’, u’E17 8QG’, u’GB’, u’13.2500000000′, u’15.0000000000′, ”, u’0E-10′, u’Online’, ‘Dots Postage and Packing’, , ‘dotship’, u’1.7500000000′, u’0E-10′, u’0E-10′, u’2010-05-05 14:13:07.134682′, u”, 713)

You can see the __proxy__ that shouldn’t be there.

Looking back at my code that provides that particular value, I found I’d used the _() shortcut, which in this file, is bound to ugettext_lazy. Of course, this is the problem! The lazy evaluation isn’t being executed before the query is evaluated.

To fix, either use gettext directly, or change the shortcut for _ from gettext_lazy to gettext.

Satchmo finally running

Woah, that wasn’t easy.

I managed to get it running using Django SVN trunk revision 8222 (pre-signals/dispatcher rewrite), and latest SVN Satchmo 1404.

It’s not easy on a PC to get the required files, got to be said.  Most of the easy_installs don’t work. 

I wasn’t sure where trml2pdf should be placed (install instructions: “put it where you want!” – thanks :-p).  I put the folder in python/site-packages, and tested with “import trml2pdf” at the python line.

Finally, all was running well and I started the shop, when I hit:
‘WSGIRequest’ object has no attribute ‘session’

This is because I used the recommended setting.py almost directly.  However, their setting-customize.py doesn’t include the “standard” stuff.  I’ve no idea why – it should have everything needed to run.  Anyway, it missed the middleware settings for the sessions.  My middleware settings now read:

MIDDLEWARE_CLASSES = (“django.middleware.locale.LocaleMiddleware”,

I still have some outstanding errors for the languages.  I had to set my LANGUAGE_CODE to “us” – pretty odd, because that’s a country code.  Doh.  Plus, I want proper English (GB), and I’ll have to make sure I can do that.

I don’t know if that’s connected to the errors I got when doing:
python manage.py satchmo_load_l10n

But I ignored that and it still seems to be running 🙂

Final note:  For a Django App, that demo store is bloody ugly ;-P

Update: Site looks better now – had to set the MEDIA_URL to ‘/static/’

Django + Satchmo: ImportError: cannot import name ImageField

I’m experimenting with Django for Dots Shop.  Satchmo seems to be the thing to use.

But it’s a real pain to install.  I keep getting the error:
ImportError: cannot import name ImageField

No-one on the Internet has mentioned this.  The only way I found to fix it was to search+replace in the Satchmo project for: 

from django.db.models.fields import ImageField

and replace with

from django.db.models.fields.files import ImageField

Four occurences.

I’m using SVN Django (a2), and Satchmo 0.7.