Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
After indexing models from MongoDB: invalid literal for int() with base 10: '4f2f7cb1dba7b152c40000e8'
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
gom  
View profile  
 More options Feb 8, 3:46 am
From: gom <lenno...@gmail.com>
Date: Wed, 8 Feb 2012 00:46:56 -0800 (PST)
Local: Wed, Feb 8 2012 3:46 am
Subject: After indexing models from MongoDB: invalid literal for int() with base 10: '4f2f7cb1dba7b152c40000e8'
I have models in a MongoDB backend. I was able to index them with
Haystack (Solr), but interacting with SearchResult objects yields an
issue:

  from haystack.query import SearchQuerySet
  results = SearchQuerySet().filter(myqueryfield="foo")
  results.count()
  --> 668  #SearchQuerySet().filter() works
  r = results[0]
  r.object
  -->  ValueError: invalid literal for int() with base 10:
'4f2f7cb1dba7b152c40000e8'

It seems to be expecting the id or pk of the object to be an int but
for mongodb it is a char hash.

Does haystack support MongDB or is there a workaround? Ultimately I'm
looking to serialize SearchQuerySet results into json so that they can
be consumed by ajax calls on the client side.

Full traceback:

ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (11, 0))
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (17, 0))
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call
last)
/home/fnord/project/<ipython-input-23-f112e546e686> in <module>()
----> 1 a.object

/home/ubuntu/lib/pip-1.0.2/src/django-haystack/haystack/models.pyc in
_get_object(self)
     71             try:
     72                 try:
---> 73                     self._object =
self.searchindex.read_queryset().get(pk=self.pk)
     74                 except NotHandled:
     75                     self.log.warning("Model '%s.%s' not
handled by the routers." % (self.app_label, self.model_name))

/usr/local/lib/python2.6/dist-packages/django/db/models/query.pyc in
get(self, *args, **kwargs)
    341         keyword arguments.
    342         """
--> 343         clone = self.filter(*args, **kwargs)
    344         if self.query.can_filter():
    345             clone = clone.order_by()

/usr/local/lib/python2.6/dist-packages/django/db/models/query.pyc in
filter(self, *args, **kwargs)
    550         set.
    551         """
--> 552         return self._filter_or_exclude(False, *args, **kwargs)
    553
    554     def exclude(self, *args, **kwargs):

/usr/local/lib/python2.6/dist-packages/django/db/models/query.pyc in
_filter_or_exclude(self, negate, *args, **kwargs)
    568             clone.query.add_q(~Q(*args, **kwargs))
    569         else:
--> 570             clone.query.add_q(Q(*args, **kwargs))
    571         return clone
    572

/usr/local/lib/python2.6/dist-packages/django/db/models/sql/query.pyc
in add_q(self, q_object, used_aliases, force_having)
   1192                 else:
   1193                     self.add_filter(child, connector,
q_object.negated,
-> 1194                             can_reuse=used_aliases,
force_having=force_having)
   1195                 if force_having:
   1196                     self.having.end_subtree()

/usr/local/lib/python2.6/dist-packages/django/db/models/sql/query.pyc
in add_filter(self, filter_expr, connector, negate, trim, can_reuse,
process_extr
as, force_having)
   1127         else:
   1128             self.where.add((Constraint(alias, col, field),
lookup_type, value),
-> 1129                 connector)
   1130
   1130
   1131         if negate:

/usr/local/lib/python2.6/dist-packages/django/db/models/sql/where.pyc
in add(self, data, connector)
     65
     66         if hasattr(obj, "prepare"):
---> 67             value = obj.prepare(lookup_type, value)
     68             super(WhereNode, self).add((obj, lookup_type,
annotation, value),
     69                 connector)

/usr/local/lib/python2.6/dist-packages/django/db/models/sql/where.pyc
in prepare(self, lookup_type, value)
    314     def prepare(self, lookup_type, value):
    315         if self.field:
--> 316             return self.field.get_prep_lookup(lookup_type,
value)
    317         return value
    318

/usr/local/lib/python2.6/dist-packages/django/db/models/fields/
__init__.pyc in get_prep_lookup(self, lookup_type, value)
    290             return value
    291         elif lookup_type in ('exact', 'gt', 'gte', 'lt',
'lte'):
--> 292             return self.get_prep_value(value)
    293         elif lookup_type in ('range', 'in'):
    294             return [self.get_prep_value(v) for v in value]

/usr/local/lib/python2.6/dist-packages/django/db/models/fields/
__init__.pyc in get_prep_value(self, value)
    477         if value is None:
    478             return None
--> 479         return int(value)
    480
    481     def contribute_to_class(self, cls, name):

ValueError: invalid literal for int() with base 10:
'4f2f7cb1dba7b152c40000e8'


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »