AP
unread,Jul 13, 2010, 12:51:43 PM7/13/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Djapian Users
Hi!
The indexer fails at processing null values in database fields:
8<---------------------------------------------------------------------------------------
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
File "/usr/local/lib/python2.6/dist-packages/Django-1.2.1-py2.6.egg/
django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/usr/local/lib/python2.6/dist-packages/Django-1.2.1-py2.6.egg/
django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.6/dist-packages/Django-1.2.1-py2.6.egg/
django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.6/dist-packages/Django-1.2.1-py2.6.egg/
django/core/management/base.py", line 218, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.6/dist-packages/Djapian-2.3.1-py2.6.egg/
djapian/management/commands/index.py", line 166, in handle
update_changes(verbose, timeout, not make_daemon, per_page,
commit_each)
File "/usr/local/lib/python2.6/dist-packages/Django-1.2.1-py2.6.egg/
django/db/transaction.py", line 338, in _commit_manually
return func(*args, **kw)
File "/usr/local/lib/python2.6/dist-packages/Djapian-2.3.1-py2.6.egg/
djapian/management/commands/index.py", line 75, in update_changes
commit_each
File "/usr/local/lib/python2.6/dist-packages/Djapian-2.3.1-py2.6.egg/
djapian/indexer.py", line 233, in update
index_value = field.convert(value, self._model)
File "/usr/local/lib/python2.6/dist-packages/Djapian-2.3.1-py2.6.egg/
djapian/indexer.py", line 44, in convert
value = '%012d' % field_value
TypeError: %d format: a number is required, not NoneType
8<---------------------------------------------------------------------------------------
The affected field is marked with "null=True" in the django model. I
solved this by adding the following line to the convert method of the
Field class (file indexer.py line 34):
8<---------------------------------------------------------------------------------------
def convert(self, field_value, model):
"""
Generates index values (for sorting) for given field value and its
content type
"""
if field_value is None:
return None
# If it is a model field make some postprocessing of its value
[...]
8<---------------------------------------------------------------------------------------
I'm using djapian 2.3.1 with django 1.2.1
--
Bye, Andreas