daevaorn / djapian

High level Xapian integration for Django
Other
6 stars 3 forks source link

django standalone #79

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I want to use djapian to index my models in a django standalone app, so I
can't use urls.py to insure indexers loading.
Trying to load_indexes() elsewhere, I don't succeed in getting it working,
each time I try to save a model I get the error:
    Obj.indexer.update()
AttributeError: type object 'Obj' has no attribute 'indexer'

How to solve this ?

Original issue reported on code.google.com by sforne...@gmail.com on 14 Sep 2009 at 9:25

GoogleCodeExporter commented 9 years ago
Putting:
import djapian
djapian.load_indexes()
at the bottom of my models.py, the above error disappears but I fall in an 
import error:
    from webapp.post.models import Obj
ImportError: No module named webapp.post.models
that I can not solve either...
(I am using djapian 2.2.4)

Original comment by sforne...@gmail.com on 14 Sep 2009 at 9:50

GoogleCodeExporter commented 9 years ago
What do you mean "django standalone app"? And why you cannot use urls.py?

Original comment by daevaorn on 14 Sep 2009 at 10:54

GoogleCodeExporter commented 9 years ago
Any webserver is running. Just a cron task script cleaning database for 
example. no
view, no template, no urls.py, just ORM.
here is some explanations:
http://www.b-list.org/weblog/2007/sep/22/standalone-django-scripts/

Original comment by sforne...@gmail.com on 14 Sep 2009 at 11:17

GoogleCodeExporter commented 9 years ago
Djapian has 2 built-in management commands. They load indexes with 
`load_indexes`
call without any problem.

Main rule here - place index loading before you want to use indexers and other
djapian's staff.

Original comment by daevaorn on 14 Sep 2009 at 11:38