johntynan / django-newsroom

Automatically exported from code.google.com/p/django-newsroom
Other
0 stars 0 forks source link

Enable update_feeds.py to run with django_settings #46

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
After running:
source env/bin/activate
then:
cd newsroom/apps/aggregator/bin
when I run python update_feeds.py
but receive the following error:

  File "update_feeds.py", line 18, in update_feeds
    from aggregator.models import Feed, FeedItem
ImportError: No module named aggregator.models

------------

I tried adding the following to the code, but still have the same issue:

sys.path.append('/home/USER/dev/code/django-newsroom/newsroom')
os.environ['DJANGO_SETTINGS_MODULE'] = 'newsroom.settings'
from django.conf import settings

Original issue reported on code.google.com by jgty...@gmail.com on 18 Apr 2009 at 10:03

GoogleCodeExporter commented 9 years ago
This is because you need to specify the pythonpath that points to the 
aggregator module.  This is something 
that is done for you when you run manage.py (manage.py hack).  

$ cat ../../../manage.py 
#!/usr/bin/env python
from django.core.management import execute_manager
import sys, os

# Include apps directory in python path
PROJECT_DIR = os.path.dirname(__file__)
sys.path.insert(0, os.path.join(PROJECT_DIR, 'apps',))

So whenever you are running scripts like this you will need to set your 
pythonpath and also specify the 
DJANGO_SETTINGS environment var.  So a cronjob to run this app would look 
similar to the wsgi deployment 
script to setup the enviornment.  But actually the better way to handle it is 
to add the update_feeds to the 
management command.  We should create an issue for this but aren't we still 
trying to decide whether to use 
jellyroll or not?  It might be too early to worry about update_feeds.py.  It's 
a minor issue.

Original comment by mand...@gmail.com on 20 Apr 2009 at 7:30

GoogleCodeExporter commented 9 years ago
I agree it's not as high a priority of an issue as others.  

As part of evaluating this tool or jellyroll, we'll want to start working with 
data,
and put some of these apps to the test.

Original comment by jgty...@gmail.com on 20 Apr 2009 at 7:37

GoogleCodeExporter commented 9 years ago
I think I have this figured out for aggregation:

a) go here: http://localhost:8000/admin/aggregator/feed/

b) add a feed (with the appropriate url to both the feed and to the public site)

c) at the command line type: ./manage.py shell

d) then run execfile("apps/aggregator/bin/update_feeds.py")

Original comment by jgty...@gmail.com on 26 Apr 2009 at 10:34

GoogleCodeExporter commented 9 years ago

Original comment by jgty...@gmail.com on 26 Apr 2009 at 11:25