Satchmo for Mobile Devices

51 views
Skip to first unread message

freb

unread,
Nov 12, 2011, 4:01:35 PM11/12/11
to Satchmo users
I'm fairly new to Satchmo but not to Django. I am creating a store and
will need a mobile version of the site. It seems to me that custom css
and templates are the way to go. This must be a pretty common task for
a Satchmo project. What is the best/least intrusive way to identify
mobile requests and render them with custom templates? Are there any
code snippets for this?

Thanks

Laszlo Antal

unread,
Nov 13, 2011, 10:51:28 AM11/13/11
to satchm...@googlegroups.com, Satchmo users
Hi,

I use a middleware to detect the mobile browser and then alter the template path. This way all the core views stay the same. I use jQueryMobile to do the heavy lifting.
Here is an example of this in action in production.
http://blackbookdailydeals.com visit it with your browser then with your mobile phone.

lzantal

> --
> You received this message because you are subscribed to the Google Groups "Satchmo users" group.
> To post to this group, send email to satchm...@googlegroups.com.
> To unsubscribe from this group, send email to satchmo-user...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/satchmo-users?hl=en.
>

Chris Moffitt

unread,
Nov 13, 2011, 12:16:36 PM11/13/11
to satchm...@googlegroups.com
On a somewhat related note, there's a thread here about satchmo-mobile -
http://groups.google.com/group/satchmo-developers/browse_thread/thread/b914d141eb42c72a

-Chris

freb

unread,
Nov 13, 2011, 9:38:09 PM11/13/11
to satchm...@googlegroups.com
Good suggestions. Thanks for mentioning jQueryMobile, looks like it will be a big help.

ionic drive

unread,
Nov 14, 2011, 3:51:33 AM11/14/11
to satchm...@googlegroups.com
I know I could have posted this to django mailing list, too.
But Multi Currency is interesting for you too. And you know
satchmo_store.shop models better than django only guys.

The story:
---------
I am working on Multi Currency
its quite finished and it works.

I have tested it on my development environment.
I installed with syncdb --all fresh and this works fine.
BUT:
---
Now I want to add it to production server. So I have to do a migration.
I want to keep the data stored in production database. (postgresql-8.4)

Short how to do a south migration:
---------------------------------
1) ./manage.py schemamigration satchmo_store.shop --init
2) ./manage.py migrate satchmo_store.shop (--fake)
3) CHANGE of models.py
4) ./manage.py schemamigration satchmo_store.shop --auto
5) ./manage.py migrate satchmo_store.shop

What app-models changed for Multi Currency?:
-------------------------------------------
Satchmo-9.0.2-py2.6.egg/product/models.py
Satchmo-9.0.2-py2.6.egg/satchmo_store.shop/models.py

How I tried to do the migration?:
--------------------------------
1) ./manage.py schemamigration satchmo_store.shop --init
2) ./manage.py migrate satchmo_store.shop --fake

[quite the same i did for Satchmo-9.0.2-py2.6.egg/product/ but let's
concentrate on satchmo_store.shop only right now.]

3)
NOW I replace the whole Satchmo-9.0.2-py2.6.egg library with my "NEW"
Multi Currency Version of Satchmo.
I removed the migrations folders in the "NEW" Version
Satchmo-9.0.2-py2.6.egg/product/migrations and
Satchmo-0.0.2-py2.6.egg/satchmo_store/shop/migrations
and replaced it in the "NEW" Multi Currency Satchmo" Version with the
migration folders from the "OLD" version, because the are up to date.

so in short: I just changed my models. (3)

4) ./manage.py schemamigration satchmo_store.shop --auto

The Problem/Error message:
-------------------------
...traceback...
django.db.utils.DatabaseError: column shop_config.currency_id does not
exist
LINE 1: ..._country_only", "shop_config"."sales_country_id",
"shop_conf...

So he is complaining about that shop_config.currency_id does not exist.
(which is a foreignkeyfield) Yeah, great. But this is the reason why I
do a migration. It did not exist in the old version. But South should
create it now. Its in the models. I already told you. When I do a fresh
database setup with syncdb --all it works.

I am really bad at migrations. What did I do wrong?
Thank you so much for your help guys!
ionic


hynekcer

unread,
Nov 14, 2011, 9:51:36 AM11/14/11
to Satchmo users
> What did I do wrong?

Reading South tutorial. The command "schemamigration" is used on the
source computer to create migration source code whereas command
"migrate" is used on the destination computer.

./manage.py migrate satchmo_store.shop --fake 0001
(or the full name 0001_name_of_your_first_migration)

./manage.py migrate satchmo_store.shop 0002

Yesterday Chris created satchmo_store/shop/migrations/0001_initial.py
Now you should read also Team Workflow and merge in
http://south.aeracode.org/docs/tutorial/part5.html
For your migrations is good convention to rename them to e.g.
0001_1_your_multicurrency and to reserve whole numbers to main
Satchmo.
0001_initial is the same as in the main row.
After Chris will create 0002_something_new, you will create merged
migration 0002_1_merged_something_new_multicurrency
0002_1

-- Hynek

ionic drive

unread,
Nov 14, 2011, 10:31:18 AM11/14/11
to satchm...@googlegroups.com
First of ALL thanks Haynek for your respond.
I am still on it :-( 48hours now. :-)

Good point to give it a special name not to crash with official
migrations.

Will respond when things are more clear to me and tell how I solved it.

Thanks
ionic

ionic drive

unread,
Nov 14, 2011, 2:44:12 PM11/14/11
to satchm...@googlegroups.com
The problem was there where some dependencies! I thought I could only
have them troubling me over multiple apps. But its also a problem in the
same app in the same models.py file.

So the solution is to do those migrations in stages.
Not trying to add a field which depends on a field which is added in the
same migration stage.

South is not directly complaining about a possible dependency issue. its
just telling the the field does not exist.

sorry for the noise!
ionic


On Mon, 2011-11-14 at 06:51 -0800, hynekcer wrote:

hynekcer

unread,
Nov 14, 2011, 7:35:19 PM11/14/11
to Satchmo users
Ionic,
IMO you can change the order of calls to db.create_table, create_field
etc. in forwards() in *schemamigration* and also change order of
delete_table in backwards().
Dependent tables and fields should be added later and removed earlier
then the independent ones.
Only with less usual *datamigration*s it could be necessary to divide
one change to more steps.

ionic drive

unread,
Nov 15, 2011, 2:40:10 AM11/15/11
to satchm...@googlegroups.com
Hynek,

--change order of calls in forwards() backwards()--
this is another good info to me.
I swear I will investigate a lot of time to become a A1 south migrator!

thx for the help and support!
Ionic

Reply all
Reply to author
Forward
0 new messages