tobych / django-fts

An export of version 25 from http://code.google.com/p/django-fts/
BSD 3-Clause "New" or "Revised" License
3 stars 2 forks source link

Issue with saving the model on self.model._meta.pk.column #2

Open eire1130 opened 12 years ago

eire1130 commented 12 years ago

When saving the model, it saves the primary key (in this case a self identified autofield called id), it also saves the reference to a foreign key, but it does not save the text nor does it save the search_index column.

Here is the traceback:

Traceback (most recent call last): File "", line 1, in File "../../project/apps\myapp\app\utils\migration.py", line 240, in migrate self.element_text[0].save() File "C:\Users\James\workspace\site\env\lib\site-packages\django\db\tran saction.py", line 217, in inner res = func(_args, _kwargs) File "c:\users\james\workspace\site\env\src\fts\fts\backends\base.py", l ine 108, in save sm._update_index(pk=self.pk) File "C:\Users\James\workspace\site\env\lib\site-packages\django\db\tran saction.py", line 217, in inner res = func(_args, _kwargs) File "c:\users\james\workspace\govini_pop\env\src\fts\fts\backends\pgsql.py", line 164, in _update_index self._update_index_update(pk) File "c:\users\james\workspace\site\env\src\fts\fts\backends\pgsql.py", line 116, in _update_index_update where = ' WHERE %s = %d' % (qn(self.model._meta.pk.column), pk) AttributeError: 'NoneType' object has no attribute 'column'

here is the dict for _meta:

None backends.searchablemodel {'unique_together': [], 'managed': True, 'order_wi th_respect_to': None, 'abstract': True, 'installed': False, 'auto_field': None, 'has_auto_field': False, 'virtual_fields': [], 'ordering': [], 'duplicate_target s': {}, 'related_fkey_lookups': [], 'object_name': 'SearchableModel', 'parents': {}, 'db_tablespace': '', 'pk': None, 'verbose_name': 'searchable model', 'get_l atest_by': None, 'concrete_managers': [], 'local_fields': [<fts.backends.pgsql.V ectorField object at 0x0391C070>], 'proxy_for_model': None, 'db_table': 'backend s_searchablemodel', 'proxy': False, 'abstract_managers': [(121, 'objects', <fts. backends.pgsql.SearchManager object at 0x0391C0B0>)], 'auto_created': False, 'pe rmissions': [], 'local_many_to_many': [], 'admin': None, '_field_name_cache': [< fts.backends.pgsql.VectorField object at 0x0391C070>], 'verbose_name_plural': <d jango.utils.functional.proxy object at 0x0391C110>, '_field_cache': ((<fts.b ackends.pgsql.VectorField object at 0x0391C070>, None),), 'app_label': 'backends ', 'module_name': 'searchablemodel'}

eire1130 commented 12 years ago

More on the above:

>>> e = ElementText.objects.get(pk=1) >>> e._meta.pk <django.db.models.fields.AutoField object at 0x035F4D70> >>> e._meta.pk.column`` 'id' >>> >>> e.element_text = 'test' >>> e.save()` Traceback (most recent call last): ... (same traceback as above)

eire1130 commented 12 years ago

I think the code from the pull request fixes above. Not really sure why it is creating two managers (of the same type) per, the first one doesn't have any fields.