Even less work you have with additionally (to ipython) installing
django-command-extensions and then running 

Linux : $ ./manage.py shell_plus 
Win: python manage.py shell_plus

It will autoload all models it can find via installed apps.

Günter
www.pal-pad.com


-----Ursprüngliche Nachricht-----
Von: [email protected] [mailto:[email protected]]
Im Auftrag von Bruce Kroeze
Gesendet: Dienstag, 28. Juli 2009 18:22
An: [email protected]
Betreff: Re: Batch product operations via shell?

On Tue, Jul 28, 2009 at 8:32 AM, Christopher Hart <[email protected]> wrote:


        Hi.. We're running Satchmmo 0.8.1 and Django 1.0.2.
        
        We had some product data-entry mistakes in what has become the live
site's database and although the mis-entered products are not active, we'd
like to delete them to tidy up the product listings in the admin interface.
        
        So, being vaguely familiar with save() and delete() from the Django
tutorials a while back, I'd like to just go into the shell and do something
like this (pseudocode.. will figure out syntax later):
        
        for product in all_products:
            if not product.is_active
                product.delete()
        
        Also, many products (there are hundreds in the store) were
accidentally not set as taxable, and they all need to be taxable. For this I
was thinking of a similar approach:
        
        for product in all_products:
            taxable = True
            taxClass = Sales
            product.save()
        
        The main questions I have are: what needs to be imported to do all
this? Is this even a sane approach? Thanks,


I do this kind of thing all the time.  Do the following:

Install ipython
$: ez_install ipython)

start the shell
$ ./manage.py shell

In [1]: from product.models import *
In [2]: # run your code here

---
Bruce Kroeze
http://solidsitesolutions.com








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

Reply via email to