Satchmo with Django 1.8 LTS

228 views
Skip to first unread message

Sheridan Small

unread,
Feb 21, 2016, 3:49:10 PM2/21/16
to Satchmo developers
I'm posting here for two reasons to let people know my experiences with Satchmo with Django 1.8 LTS and to get a sanity check that what I have done to get it to work is sensible as I don't fully understand what the consequences may be.

Starting with the latest bitbucket version of Satchmo (after commit a784ed7) I installed it with Django 1.8. I ran into several minor issues which I seem to have overcome but wanted to check that what I have done to fix these issues is sensible.
I used the latest versions when I installed with pip except for app_plugins which I will come to later.

The first issue was that I got an error message, Application labels aren't unique, duplicates: thumbnail. In INSTALLED_APPS I had both 'sorl.thumbnail' and #satchmo_utils.thumbnail' I don't think I use  'satchmo_utils.thumbnail' so I commented it out.

The next issue I came to was when i ran syncdb I got the error livesettings.models.SettingNotSet: ("Startup error, couldn't load PAYMENT_PAYPAL.KEY", None). I also got it for PAYMENT_GIFTCERTIFICATE and PAYMENT_DUMMY if I used these instead. So I added:
LIVESETTINGS_OPTIONS = \
{   1L: {   'DB': False,
            'SETTINGS': {   u'PAYMENT_DUMMY': {   u'CREDITCHOICES': u'["Visa", "Mastercard", "Discover", "American Express"]',
                                                  u'LIVE': u'True'},
                            u'PAYMENT_GIFTCERTIFICATE': {   u'LIVE': u'True'},
                            u'PAYMENT_PAYPAL': {   u'BUSINESS': u'xxx',
                                                   u'BUSINESS_TEST': u'xxx',
                                                   u'CURRENCY_CODE': u'GBP'},
                            u'SHOP': {   u'REQUIRED_BILLING_DATA': u'["email", "first_name", "last_name", "phone", "street1", "city", "postal_code", "country"]',
                                         u'REQUIRED_SHIPPING_DATA': u'["addressee", "street1", "city", "postal_code", "country"]'}}}}

to my settings.py. Syncdb worked I commented the LIVESETTINGS_OPTIONS out and ran syncdb again and it still worked.

The final issue was with app_plugins. I ran into an error "TemplateSyntaxError at / 'app_plugins' is not a valid tag library: ImportError raised loading app_plugins.templatetags.app_plugins: cannot import name CacheClass. A bit of Googling  https://docs.djangoproject.com/es/1.9/releases/1.8/ says "The CacheClass shim has been removed from all cache backends. These aliases were provided for backwards compatibility with Django 1.3. If you are still using them, please update your project to use the real class name found in the BACKEND key of the CACHES setting."
So I cloned ssh://h...@bitbucket.org/bkroeze/django-caching-app-plugins and copied the app_plugins directory to my project directory, edited app_plugins.py commenting out the offending line and adding a new one like this:

#from django.core.cache.backends.locmem import CacheClass as LocalMemCache
from django.core.cache.backends.memcached import MemcachedCache as LocalMemCache

Then I ran into an error "AttributeError at / 'Template' object has no attribute 'nodelist'.
Googling it again I found I could (but I don't really understand what I am doing) update the function inclusion_kwdtag in app_plugins.py commenting out a line and adding a line like this:

def inclusion_kwdtag(register, file_name, context_class=Context,
                      takes_context=False):
        def dec(func):
            class InclusionKwdNode(Node):
                def __init__(self, vars_to_resolve):
                    self.vars_to_resolve = map(Variable, vars_to_resolve)

                def render(self, context):
                    new_context = callback(func, self.vars_to_resolve, context,
                                           takes_context)
                    if not getattr(self, 'nodelist', False):
                        if (not isinstance(file_name, basestring) and
                            is_iterable(file_name)):
                            t = loader.select_template(file_name)
                        else:
                            #t = loader.get_template(file_name)
                            #added line
                            t = context.template.engine.get_template(file_name)

Now everything seems to work although I still have further testing to do. However I would appreciate it if someone who understands this better can clarify if I have done anything stupid or not.

Sheridan Small

unread,
Feb 27, 2016, 4:48:40 PM2/27/16
to Satchmo developers
Sine I originally posted last week predatell has made a pull request #4: django 1.8  on django-caching-app-plugins  which  Chris Moffitt kindly merged into the default branch. This update is much more elegant than my ugly hack for django-caching-app-plugins. I have tested it and it addresses the issue I had with django-caching-app-plugin.
So I have a working installation of Satchmo with Django 1.8 LTS. I will continue to test and publish any further issues here.

Rick Entress

unread,
Feb 29, 2016, 10:42:17 AM2/29/16
to Satchmo developers
Getting satchmo to work with versions of Django > 1.4 is a very long standing need and request from all active users of the library. 

Whilst you seem to have successfully bootstrapped your way to a working build, there will be many more issues than these - you should certainly not assume your satchmo build will work with 1.8.

I don't know how close we are to releasing an updated satchmo version to get past 1.4, but it can't come soon enough.

or...@oriontecharts.com

unread,
Feb 29, 2016, 10:42:22 AM2/29/16
to Satchmo developers
Do you mind sharing your requirements.txt file? I was also able to upgrade from 1.4 to 1.8 but I'm having some issues when changing product information. I will write more details after I try a couple of things.

There is another repository for django-caching-app-plugins https://bitbucket.org/freakypie/django-caching-app-plugins/ I'm not sure if there is a part of satchmo that depend on app-plugins so I haven't made any tests but this repository did fix the error.

Sheridan Small

unread,
Feb 29, 2016, 4:00:13 PM2/29/16
to Satchmo developers
My requirements.txt file that I used for the install contains:

Django==1.8
MySQL-python
Pillow
PyYAML
South
argparse
django-keyedcache
django-livesettings
django-registration
django-threaded-multihost
pycrypto
reportlab
sorl-thumbnail==12.3
wsgiref
django-smtp-ssl
pyopenssl
ndg-httpsclient
pyasn1
django-debug-toolbar
django-contrib-comments

pip freeze gives this:
apt-xapian-index==0.45
chardet==2.0.1
Cheetah==2.4.4
cloud-init==0.7.5
colorama==0.2.5
configobj==4.7.2
Django==1.8
django-contrib-comments==1.6.2
django-debug-toolbar==1.4
django-keyedcache==1.5.1
django-livesettings==1.4.post16
django-registration==2.0.4
django-smtp-ssl==1.0
django-threaded-multihost==1.4.post1
docutils==0.11
html5lib==0.999
jsonpatch==1.3
jsonpointer==1.0
Landscape-Client==14.12
Markdown==2.4
MySQL-python==1.2.5
ndg-httpsclient==0.4.0
oauth==1.0.1
PAM==0.4.2
Pillow==2.3.0
prettytable==0.7.2
pyasn1==0.1.9
pycrypto==2.6.1
pycurl==7.19.3
Pygments==1.6
pyOpenSSL==0.13
pyserial==2.6
python-apt===0.9.3.5ubuntu2
python-debian===0.1.21-nmu2ubuntu2
python-memcached==1.53
PyYAML==3.10
reportlab==3.0
requests==2.2.1
roman==2.0.0
six==1.5.2
sorl-thumbnail==12.3
South==1.0.2
sqlparse==0.1.18
ssh-import-id==3.21
textile==2.1.5
TRML2PDF==1.0
Twisted-Core==13.2.0
Twisted-Names==13.2.0
Twisted-Web==13.2.0
urllib3==1.7.1
wheel==0.24.0
zope.interface==4.0.5

Although I have some things installed with Pip that are not Satchmo related.

I was not doing an update but a fresh install which I guess is easier. I was unaware of https://bitbucket.org/freakypie/django-caching-app-plugins/ thanks for letting me know about it.

I have encountered two further minor issues one with adding or changing a product it seems to want the "Prices" ->  "Price" fields populated for each row displayed, but if you give it the same price as the first it seems to ignore it.
Also pop ups don't work they seem to be missing a JavaScript file but that may be my templates, I will have to investigate further.
Otherwise I can add products including custom products add them to a customers cart and checkout with PayPal sandbox or the dummy payment module.

Sheridan Small

unread,
Feb 29, 2016, 4:08:30 PM2/29/16
to Satchmo developers
Agreed, but by posting here I hope to provide some momentum to getting these issues fixed.

Orion Vianna

unread,
Mar 1, 2016, 1:39:50 PM3/1/16
to satchmo-d...@googlegroups.com
Thanks for sharing the requirements file.
I see the same issue when saving a product. A quick way to make that go away is to set extra = 0 on line 98 on apps/product/admin.py

There is also an issue when saving/editing an order. This is what I see when I look at the output code      
<div class="form-row errors hidden field-contact">
            <ul class="errorlist"><li>This field is required.</li></ul>

I also have a problem when clicking thumbnails. It does not load the larger image. I think it's a path or cache issue (the URL is pointing to cache folder) but I haven't looked in to this yet.
--
You received this message because you are subscribed to the Google Groups "Satchmo developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to satchmo-develop...@googlegroups.com.
To post to this group, send email to satchmo-d...@googlegroups.com.
Visit this group at https://groups.google.com/group/satchmo-developers.
For more options, visit https://groups.google.com/d/optout.

Orion Vianna

unread,
Mar 1, 2016, 10:17:36 PM3/1/16
to satchmo-d...@googlegroups.com
It turned out the thumbnail template issue was a missing largeimage.url instead of largeimage which did not provide the proper URL. This problem was unique to my templates, I think the satchmo src is OK.

There is still a problem with the hidden field error when editing an order in the admin. That is what I will look in to next.

Sheridan Small

unread,
Mar 4, 2016, 7:14:31 PM3/4/16
to Satchmo developers
First of all I can confirm your fix of "A quick way to make that go away is to set extra = 0 on line 98 on apps/product/admin.py" works for me as I only have one price for a product. The workaround suits me but maybe not everyone as they may need more than one price for certain products. If I get a chance I'll look into it further.

I can't comment on the thumbnails as my templates don't use them.

I looked at editing an order and I saw encoded HTML in the page source. Trying to save it gave the same error you had.
I updated the code starting at about line 75 to about line 123. I changed it so that what was returned was of type 'django.utils.safestring.SafeBytes' not 'unicode' as I guess was originally intended.
I also fixed the URLs of some images.

        return mark_safe(rendered + u'''
            <style type="text/css" media="screen">
                #lookup_%(name)s {
                    padding-right:16px;
                    background: url(
                        %(static_url)sadmin/img/selector-search.gif
                    ) no-repeat right;
                }
                #del_%(name)s {
                    display: none;
                }
            </style>
<input type="text" id="lookup_%(name)s" value="%(label)s"/>
<a href="#" id="del_%(name)s">
<img src="%(static_url)sadmin/img/icon_deletelink.gif" />
</a>
<script type="text/javascript">
            var lookup = $('#lookup_%(name)s')
            if (lookup.val()) {
                $('#del_%(name)s').show()
            }
            lookup.attr('size', Math.max(40, lookup.attr('value').length))
            lookup.autocomplete('../search/', {
                formatResult: function(data){ return $('<div />').html(data[0]).text(); },
                extraParams: {
                    search_fields: '%(search_fields)s',
                    app_label: '%(app_label)s',
                    model_name: '%(model_name)s'
                }
            }).result(function(event, data, formatted) {
                if (data) {
                    $('#id_%(name)s').val(data[1]);
                    $('#del_%(name)s').show();
                }
            });
            $('#del_%(name)s').click(function(ele, event) {
                $('#id_%(name)s').val('');
                $('#del_%(name)s').hide();
                $('#lookup_%(name)s').val('');
            });
            </script>
        ''' % {
            'search_fields': ','.join(self.search_fields),
            'static_url': settings.STATIC_URL,
            'model_name': model_name,
            'app_label': self.rel.to._meta.app_label,
            'label': label,
            'name': name,
        })

I guess I should test it on 1.4 and make a pull request if it is OK.

Sheridan Small

unread,
Mar 4, 2016, 7:21:03 PM3/4/16
to Satchmo developers
Forgot to mention which file it was: satchmo_utils/admin.py

Orion Vianna

unread,
Mar 4, 2016, 7:31:35 PM3/4/16
to satchmo-d...@googlegroups.com
This is great! I also saw that code escaping issue. There is CSS hiding that form in the new Django version <div class="form-row hidden field-contact"> I think this is the code that is adding the hidden class  https://github.com/django/django/commit/dc3d2ac98c1bcfad74d3e9523caf07e7e9fb15aa

Sheridan Small

unread,
Mar 4, 2016, 7:54:32 PM3/4/16
to Satchmo developers
Just to clarify things... I think the encoding issue was causing it to not save on an update. It was also causing similar issues elsewhere in the admin section. With this change the encoding issue has gone, it now saves properly on an update and I fixed the URLs for some images. I would be grateful if you could test it to see if it works for you and if you could post any further issues you have running it with Django 1,8 here.

Orion Vianna

unread,
Mar 4, 2016, 8:13:21 PM3/4/16
to satchmo-d...@googlegroups.com
Thanks for verifying the quick fix. Can you kindly verify if its still
possible to have more then one price by clicking Add another price and
setting a date (date is required). It works OK here.

I think I never used this price function before. It's used to schedule a
price change and it requires the command line ./manage.py
satchmo_rebuild_pricing in a daily cron job for it to work
http://satchmo.readthedocs.org/en/latest/pricing.html#expiring-pricing

I'm getting some errors on ./manage.py satchmo_rebuild_pricing but I
don't know how significant they are yet. Here is part of the error
heheh....

Fri, 04 Mar 2016 20:01:14 iterchoices ERROR Internal error in
introspect_management_command. Report it to the author: hynekcer


On 03/04/2016 07:14 PM, Sheridan Small wrote:

Orion Vianna

unread,
Mar 4, 2016, 8:13:36 PM3/4/16
to satchmo-d...@googlegroups.com
I believe contact have the same problem.
--

Orion Vianna

unread,
Mar 4, 2016, 8:54:08 PM3/4/16
to satchmo-d...@googlegroups.com
It works OK here but the field is hidden.

To clarify, orders used to have the costumers name and email on top of
the page (below Site:). I believe this changed because of the following
django commit
https://github.com/django/django/commit/dc3d2ac98c1bcfad74d3e9523caf07e7e9fb15aa.
Now the name and email is hidden with the CSS .

.hidden {
display: none;
}

Removing hidden from <div class="form-row hidden field-contact"> (try
with chrome inspector) will reveal name and email again.

My suggestion may not be the cleanest way to fix this but but adding

.field-contact {
display: block;
}

to the CSS section of the code you sent me (line 86 on
satchmo/apps/satchmo_utils/admin.py) seems to do the trick.

On 03/04/2016 07:54 PM, Sheridan Small wrote:

Orion Vianna

unread,
Mar 4, 2016, 8:59:30 PM3/4/16
to satchmo-d...@googlegroups.com
My apologies, what I meant was

.field-%(name)s {
display: block;

Sheridan Small

unread,
Mar 5, 2016, 2:42:20 AM3/5/16
to Satchmo developers
My apologies, I had the old 1.4 files in my staticdirs so the new ones don't got collected. You are right on both counts; you can add another price and you need to add your css fix.
For the record, I have tested the code on 1.4 it works fine. I do not think I have introduced a XSS vulnerability as the string "rendered" contains something like "<input type="hidden" name="contact" value="3" id="id_contact" />" not user submitted content.

Sheridan Small

unread,
Mar 5, 2016, 3:41:29 PM3/5/16
to Satchmo developers

Just to let you know I can not reproduce this error you saw, the command
    sudo python manage.py satchmo_rebuild_pricing
works fine for me with just RemovedInDjango19Warnings

Sheridan Small

unread,
Mar 24, 2016, 6:41:26 PM3/24/16
to Satchmo developers
I created a pull request to incorporate these changes and one other into Satchmo https://bitbucket.org/chris1610/satchmo/pull-requests/90/minor-changes-to-get-satchmo-to-work-with/diff

Sheridan Small

unread,
Mar 25, 2016, 5:25:51 PM3/25/16
to Satchmo developers
The pull request has now been merged into the default branch of Satchmo.
Reply all
Reply to author
Forward
0 new messages