if I were you,
I also will create a django command to call the utility,
it much easier that way.

-djibon-

On Mon, Jan 18, 2010 at 7:20 AM, nek4life <nek4l...@gmail.com> wrote:
> On Jan 17, 4:58 pm, lance <lan...@gmail.com> wrote:
>> Python/Django newbie question:
>>
>> I need to create a cron job that fetches json data from a URL, parses
>> it (presumably using simplejson) and then load the data into my
>> database using the Django models I've defined.
>>
>> I'm having trouble finding any tips, examples, or documentation on how
>> to do this... any help is greatly appreciated.
>
> I did something similar using the delicious api and elementtree to
> parse the data.
>
> First I created a module called utils.py in my application package and
> wrote a script for grabbing the url, parsing the data and updating the
> database.  Then I created another script called cron.py to run the
> utils.py every so often.  In the cron script you'll have to set your
> environmental variables for your project like so.
>
> import os
> import sys
> import site
>
> site.addsitedir('/opt/pythonenv/example.com/lib/python2.5/site-
> packages') # virtual environment
> sys.path.append('/var/www/vhosts/example.com/') # project location
> os.environ['DJANGO_SETTINGS_MODULE'] = 'project.settings' # settings
> file
>
> # import your module and then call it
>
> As far as using simplejson goes I haven't used it before.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>
>
>



-- 
--------------------------------------------------------------
http://www.tumbletooth.org
my linkedin profile : http://www.linkedin.com/in/bayuadji
--------------------------------------------------------------
-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to