run manage.py commands within app

39 views
Skip to first unread message

judy wawira

unread,
Mar 23, 2014, 7:46:00 PM3/23/14
to django...@googlegroups.com
Hello I have a django app using haystack and a solr backend to power searches

There is dynamic addition of data and wonder if there are other ways to automatically rebuild the solr index without manually going to the command line to run manage.py rebuild_index

Thanks

Lachlan Musicman

unread,
Mar 23, 2014, 8:22:05 PM3/23/14
to django...@googlegroups.com
I use cron and a script - but would love to hear other methods as well.

Notes: Need to add virtualenv to PATH:

crontab -e

SHELL=/bin/bash
PATH=/home/erp/.virtualenvs/prod/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

#
# m h dom mon dow command
0 * * * * cd /home/www/prod/erp/ && python manage.py update_index
--settings=erp.settings.production >> /tmp/cronupdate.log 2>&1 &&
python manage.py build_solr_schema --filename=schema.xml
--settings=erp.settings.production >> /tmp/cronbuild.log 2>&1 && cp
schema.xml /opt/solr/erp/conf/
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/7a8c9a7f-b15c-4d4e-9b43-cc54c977f125%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
From this perspective it is natural that anarchism be marked by
spontaneity, differentiation, and experimentation that it be marked by
an expressed affinity with chaos, if chaos is understood to be what
lies outside or beyond the dominant game or system. Because of the
resistance to definition and categorisation, the anarchist principle
has been variously interpreted as, rather than an articulated
position, “a moral attitude, an emotional climate, or even a mood”.
This mood hangs in dramatic tension between utopian hope or dystopian
nihilism...
-----
http://zuihitsu.org/godspeed-you-black-emperor-and-the-politics-of-chaos

Tom Evans

unread,
Mar 25, 2014, 6:33:55 AM3/25/14
to django...@googlegroups.com
from django.core import management
management.call_command('rebuild_index',)


Cheers

Tom
Reply all
Reply to author
Forward
0 new messages