Django and AuthOpenId error - django

I'm trying to set up OpenID authentication in Django, using django-authopenid.
The instructions are pretty good, but having followed them and made all the requisite changes in settings.py and added the required templates, my whole site is now showing a 500 error, having previously worked fine. The Apache logs show:
Exception occurred processing WSGI script '/usr/local/www/wsgi-scripts/myapp.wsgi'.
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/wsgi.py", line 241, in __call__
response = self.get_response(request)
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py", line 73, in get_response
response = middleware_method(request)
File "/usr/local/lib/python2.6/dist-packages/django_authopenid-1.0.1-py2.6.egg/django_authopenid/middleware.py", line 36, in process_request
request.associated_openids = [rel.openid_url for rel in rels]
File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py", line 93, in _result_iter
self._fill_cache()
File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py", line 660, in _fill_cache
self._result_cache.append(self._iter.next())
File "/usr/local/lib/python2.6/dist-packages/django/db/models/query.py", line 207, in iterator
for row in self.query.results_iter():
File "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/query.py", line 287, in results_iter
for rows in self.execute_sql(MULTI):
File "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/query.py", line 2345, in execute_sql
cursor.execute(sql, params)
File "/usr/local/lib/python2.6/dist-packages/django/db/backends/util.py", line 19, in execute
return self.cursor.execute(sql, params)
ProgrammingError: relation "django_authopenid_userassociation" does not exist
Looks like a SQL error (I'm not a django expert)?
It's possible I've put my templates in the wrong place, the instructions aren't very clear. I just added two new directories, registration and openauthid, in the main templates folder.
Bit baffled - can anyone help? Thanks!

It looks to me like you've not yet set up the required tables. Try running:
python manage.py syncdb
from the project directory.

Related

test_database() does not use the database given

I'm trying to test my models using peewee's test_database which is supposed to use the database passed when executing the SQL in the context block. However running the test, I noticed that the production database is always used, which should not be the case.
Here's the exception I get:
======================================================================
ERROR: test_Admin (__main__.DatabaseTestSuite)
----------------------------------------------------------------------
Traceback (most recent call last):
File "db/db_test.py", line 14, in test_Admin
with test_database(test_db, (Admin), create_tables=True):
File "/usr/local/lib/python2.7/dist-packages/playhouse/test_utils.py", line 21, in __enter__
for m in self.models:
File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 4723, in __iter__
return iter(self.select())
File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 3149, in __iter__
return iter(self.execute())
File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 3142, in execute
self._qr = ResultWrapper(model_class, self._execute(), query_meta)
File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 2826, in _execute
return self.database.execute_sql(sql, params, self.require_commit)
File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 3683, in execute_sql
self.commit()
File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 3507, in __exit__
reraise(new_type, new_type(*exc_args), traceback)
File "/usr/local/lib/python2.7/dist-packages/peewee.py", line 3676, in execute_sql
cursor.execute(sql, params or ())
File "/usr/local/lib/python2.7/dist-packages/pymysql/cursors.py", line 166, in execute
result = self._query(query)
File "/usr/local/lib/python2.7/dist-packages/pymysql/cursors.py", line 322, in _query
conn.query(q)
File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 835, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 1019, in _read_query_result
result.read()
File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 1302, in read
first_packet = self.connection._read_packet()
File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 981, in _read_packet
packet.check_error()
File "/usr/local/lib/python2.7/dist-packages/pymysql/connections.py", line 393, in check_error
err.raise_mysql_exception(self._data)
File "/usr/local/lib/python2.7/dist-packages/pymysql/err.py", line 107, in raise_mysql_exception
raise errorclass(errno, errval)
ProgrammingError: (1146, u"Table 'db.admin' doesn't exist")
----------------------------------------------------------------------
Here's the test code:
from db import *
import unittest
from playhouse.test_utils import test_database
test_db = MySQLDatabase('testdb',
user='testuser',
password='testpass')
class DatabaseTestSuite(unittest.TestCase):
def test_Admin(self):
with test_database(test_db, (Admin), create_tables=True):
Admin.create(username="testuser",
email="testuser#email.com")
result = Admin.select().where(Admin.user == "testuser")
unittest.assertIsNotNone(result)
if __name__ == '__main__':
unittest.main()
I've opened an issue on the github page, but received no help so far. You can find the issue here. It should provide extra details if needed. Any help would be appreciated, thanks.
The model tuple has a single item and thus requires a trailing comma. Changing this
with test_database(test_db, (Admin), create_tables=True):
to this
with test_database(test_db, (Admin,), create_tables=True):
resolved it.

Unable to rebuild index in django haystack

I am trying to run manage.py rebuild_index but getting below error.
`(django_project)deep#deep-ThinkPad-Edge:~/doroko$ python manage.py rebuild_index No handlers could be found for logger "django_facebook.models" /home/deep/.virtualenvs/django_project/local/lib/python2.7/site-packages/django/utils/image.py:150: RemovedInDjango18Warning: Support for the PIL will be removed in Django 1.8. Please uninstall it & install Pillow instead. RemovedInDjango18Warning
System check identified some issues:
WARNINGS: ?: (1_6.W001) Some project unittests may not execute as expected. HINT: Django 1.6 introduced a new default test runner. It looks like this project was generated using Django 1.5 or earlier. You should ensure your tests are all running & behaving as expected. See https://docs.djangoproject.com/en/dev/releases/1.6/#new-test-runner for more information. System check identified some issues:
WARNINGS: ?: (1_6.W001) Some project unittests may not execute as expected. HINT: Django 1.6 introduced a new default test runner. It looks like this project was generated using Django 1.5 or earlier. You should ensure your tests are all running & behaving as expected. See https://docs.djangoproject.com/en/dev/releases/1.6/#new-test-runner for more information.
WARNING: This will irreparably remove EVERYTHING from your search index in connection 'default'. Your choices after this are to restore from backups or rebuild via the `rebuild_index` command. Are you sure you wish to continue? [y/N] y Removing all documents from your index because you said so. Failed to clear Elasticsearch index: ConnectionError(('Connection aborted.', error(111, 'Connection refused'))) caused by: ProtocolError(('Connection aborted.', error(111, 'Connection refused'))) All documents removed. System check identified some issues:
WARNINGS: ?: (1_6.W001) Some project unittests may not execute as expected. HINT: Django 1.6 introduced a new default test runner. It looks like this project was generated using Django 1.5 or earlier. You should ensure your tests are all running & behaving as expected. See https://docs.djangoproject.com/en/dev/releases/1.6/#new-test-runner for more information. Indexing 34 wishs ERROR:root:Error updating feed using default Traceback (most recent call last): File "/home/deep/.virtualenvs/django_project/local/lib/python2.7/site-packages/haystack/management/commands/update_index.py", line 189, in handle_label
self.update_backend(label, using) File "/home/deep/.virtualenvs/django_project/local/lib/python2.7/site-packages/haystack/management/commands/update_index.py", line 234, in update_backend
do_update(backend, index, qs, start, end, total, self.verbosity) File "/home/deep/.virtualenvs/django_project/local/lib/python2.7/site-packages/haystack/management/commands/update_index.py", line 89, in do_update
backend.update(index, current_qs) File "/home/deep/.virtualenvs/django_project/local/lib/python2.7/site-packages/haystack/backends/elasticsearch_backend.py", line 164, in update
prepped_data = index.full_prepare(obj) File "/home/deep/.virtualenvs/django_project/local/lib/python2.7/site-packages/haystack/indexes.py", line 207, in full_prepare
self.prepared_data = self.prepare(obj) File "/home/deep/doroko/feed/search_indexes.py", line 16, in prepare
data = super(feedIndex, self).prepare(obj) File "/home/deep/.virtualenvs/django_project/local/lib/python2.7/site-packages/haystack/indexes.py", line 198, in prepare
self.prepared_data[field.index_fieldname] = field.prepare(obj) File "/home/deep/.virtualenvs/django_project/local/lib/python2.7/site-packages/haystack/fields.py", line 159, in prepare
return self.convert(super(CharField, self).prepare(obj)) File "/home/deep/.virtualenvs/django_project/local/lib/python2.7/site-packages/haystack/fields.py", line 165, in convert
return six.text_type(value) File "/home/deep/.virtualenvs/django_project/local/lib/python2.7/site-packages/django/db/models/manager.py", line 81, in __str__
in opts.concrete_managers + opts.abstract_managers StopIteration Traceback (most recent call last): File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv) File "/home/deep/.virtualenvs/django_project/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute() File "/home/deep/.virtualenvs/django_project/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/deep/.virtualenvs/django_project/local/lib/python2.7/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__) File "/home/deep/.virtualenvs/django_project/local/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options) File "/home/deep/.virtualenvs/django_project/local/lib/python2.7/site-packages/haystack/management/commands/rebuild_index.py", line 16, in handle
call_command('update_index', **options) File "/home/deep/.virtualenvs/django_project/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 115, in call_command
return klass.execute(*args, **defaults) File "/home/deep/.virtualenvs/django_project/local/lib/python2.7/site-packages/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options) File "/home/deep/.virtualenvs/django_project/local/lib/python2.7/site-packages/haystack/management/commands/update_index.py", line 184, in handle
return super(Command, self).handle(*items, **options) File "/home/deep/.virtualenvs/django_project/local/lib/python2.7/site-packages/django/core/management/base.py", line 503, in handle
label_output = self.handle_label(label, **options) File "/home/deep/.virtualenvs/django_project/local/lib/python2.7/site-packages/haystack/management/commands/update_index.py", line 189, in handle_label
self.update_backend(label, using) File "/home/deep/.virtualenvs/django_project/local/lib/python2.7/site-packages/haystack/management/commands/update_index.py", line 234, in update_backend
do_update(backend, index, qs, start, end, total, self.verbosity) File "/home/deep/.virtualenvs/django_project/local/lib/python2.7/site-packages/haystack/management/commands/update_index.py", line 89, in do_update
backend.update(index, current_qs) File "/home/deep/.virtualenvs/django_project/local/lib/python2.7/site-packages/haystack/backends/elasticsearch_backend.py", line 164, in update
prepped_data = index.full_prepare(obj) File "/home/deep/.virtualenvs/django_project/local/lib/python2.7/site-packages/haystack/indexes.py", line 207, in full_prepare
self.prepared_data = self.prepare(obj) File "/home/deep/doroko/feed/search_indexes.py", line 16, in prepare
data = super(feedIndex, self).prepare(obj) File "/home/deep/.virtualenvs/django_project/local/lib/python2.7/site-packages/haystack/indexes.py", line 198, in prepare
self.prepared_data[field.index_fieldname] = field.prepare(obj) File "/home/deep/.virtualenvs/django_project/local/lib/python2.7/site-packages/haystack/fields.py", line 159, in prepare
return self.convert(super(CharField, self).prepare(obj)) File "/home/deep/.virtualenvs/django_project/local/lib/python2.7/site-packages/haystack/fields.py", line 165, in convert
return six.text_type(value) File "/home/deep/.virtualenvs/django_project/local/lib/python2.7/site-packages/django/db/models/manager.py", line 81, in __str__
in opts.concrete_managers + opts.abstract_managers StopIteration`
This is the search_indexes.py file for model.
import datetime
from haystack import indexes
from feed.models import Wish
class feedIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
wish_text = indexes.CharField(model_attr='wish_text',null=True)
tags = indexes.CharField(model_attr='tags')
added = indexes.DateTimeField(model_attr='added')
def get_model(self):
return Wish
def prepare_wish_text(self, obj):
return "Wish"
def prepare(self, obj):
data = super(feedIndex, self).prepare(obj)
data["_boost"] = 1.5
return data
Following are versions used :
Django==1.7.6
django-haystack==2.3.1
elasticsearch==1.4.0
pyelasticsearch==0.5
Testing seems to suggest this comes up if a search template is incorrectly configured.
Double check all the fields in your search template and find the incorrect one and the issue should resolve.
https://groups.google.com/forum/#!topic/django-haystack/InXrimOyHtQ

AttributeError: 'NoneType' object has no attribute 'tags'

Traceback (most recent call last):<br/>
File "/home/rpmbuild/venv/build/pyi.linux2/MF/out00-PYZ.pyz/cherrypy.wsgiserver.wsgiserver2", line 1353, in communicate<br/>
File "/home/rpmbuild/venv/build/pyi.linux2/MF/out00-PYZ.pyz/cherrypy.wsgiserver.wsgiserver2", line 868, in respond<br/>
File "/home/rpmbuild/venv/build/pyi.linux2/MF/out00-PYZ.pyz/cherrypy.wsgiserver.wsgiserver2", line 2267, in respond<br/>
File "/home/rpmbuild/venv/build/pyi.linux2/MF/out00-PYZ.pyz/cherrypy.wsgiserver.wsgiserver2", line 2477, in __call__<br/>
File "/home/rpmbuild/venv/build/pyi.linux2/MF/out00-PYZ.pyz/django.core.handlers.wsgi", line 206, in __call__<br/>
File "/home/rpmbuild/venv/build/pyi.linux2/MF/out00-PYZ.pyz/django.core.handlers.base", line 194, in get_response<br/>
File "/home/rpmbuild/venv/build/pyi.linux2/MF/out00-PYZ.pyz/django.core.handlers.base", line 229, in handle_uncaught_exception<br/>
File "/home/rpmbuild/venv/build/pyi.linux2/MF/out00-PYZ.pyz/django.views.debug", line 69, in technical_500_response<br/>
File "/home/rpmbuild/venv/build/pyi.linux2/MF/out00-PYZ.pyz/django.views.debug", line 322, in get_traceback_html<br/>
File "/home/rpmbuild/venv/build/pyi.linux2/MF/out00-PYZ.pyz/django.template.base", line 125, in __init__<br/>
File "/home/rpmbuild/venv/build/pyi.linux2/MF/out00-PYZ.pyz/django.template.base", line 152, in compile_string<br/>
File "home/rpmbuild/venv/build/pyi.linux2/MF/out00-PYZ.pyz/django.template.debug", line 35, in __init__<br/>
File "/home/rpmbuild/venv/build/pyi.linux2/MF/out00-PYZ.pyz/django.template.base", line 239, in __init__<br/>
File "/home/rpmbuild/venv/build/pyi.linux2/MF/out00-PYZ.pyz/django.template.base", line 353, in add_library<br/>
AttributeError: 'NoneType' object has no attribute 'tags'
I have pyinstaller for django project running on cherrypy server.
its working from python manage.py runserver from command prompt
not working using bundled through pyinstaller.
I have tested for both development environment and production environment in settings.py
DEBUG = False/True<br>
Allowed_HOSTS = ['*']
Somewhere you use the code like this:
<something>.tags
where is estimated to None
If you use django.contrib.markup.templatetags.markup so this is the problem, because django.contrib.markup.templatetags.markup is depricated

How to install neo4django in virtual environment

I receive the error below when trying to install neo4django in my virtual environment. Not sure what the problem is. The server is running on my machine and py2neo works with the restful api, but not neo4django.
I'm running ubuntu 12.0.4 with the latest version of neo4j installed (1.9-M01) and jdk 1.7 (openjkd) installed with JAVA_HOME pointing to: /usr/lib/jvm/java-7-openjdk-amd64
Traceback (most recent call last): File "manage.py", line 10, in
execute_from_command_line(sys.argv) File "/home/alan/workspace/neowiki/venv/local/lib/python2.7/site-packages/django/core/management/init.py",
line 443, in execute_from_command_line
utility.execute() File "/home/alan/workspace/neowiki/venv/local/lib/python2.7/site-packages/django/core/management/init.py",
line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/alan/workspace/neowiki/venv/local/lib/python2.7/site-packages/django/core/management/base.py",
line 196, in run_from_argv
self.execute(*args, **options.dict) File "/home/alan/workspace/neowiki/venv/local/lib/python2.7/site-packages/django/core/management/base.py",
line 232, in execute
output = self.handle(*args, **options) File "/home/alan/workspace/neowiki/neowiki/nodes/management/commands/testcmd.py",
line 10, in handle
pete = Person.objects.create(name='Pete') File "/home/alan/workspace/neowiki/venv/local/lib/python2.7/site-packages/neo4django/db/models/manager.py",
line 41, in create
return self.get_query_set().create(*kwargs) File "/home/alan/workspace/neowiki/venv/local/lib/python2.7/site-packages/neo4django/db/models/query.py",
line 747, in create
return super(NodeQuerySet, self).create(*kwargs) File "/home/alan/workspace/neowiki/venv/local/lib/python2.7/site-packages/django/db/models/query.py",
line 377, in create
obj.save(force_insert=True, using=self.db) File "/home/alan/workspace/neowiki/venv/local/lib/python2.7/site-packages/neo4django/db/models/base.py",
line 325, in save
return super(NodeModel, self).save(using=using, **kwargs) File "/home/alan/workspace/neowiki/venv/local/lib/python2.7/site-packages/django/db/models/base.py",
line 463, in save
self.save_base(using=using, force_insert=force_insert, force_update=force_update) File
"/home/alan/workspace/neowiki/venv/local/lib/python2.7/site-packages/neo4django/db/models/base.py",
line 340, in save_base
self._save_neo4j_node(using) File "", line 2, in _save_neo4j_node File "/home/alan/workspace/neowiki/venv/local/lib/python2.7/site-packages/neo4django/db/models/base.py",
line 115, in trans_method
ret = func(*args, **kw) File "/home/alan/workspace/neowiki/venv/local/lib/python2.7/site-packages/neo4django/db/models/base.py",
line 370, in _save_neo4j_node
typesToIndex=type_names_to_index) File "/home/alan/workspace/neowiki/venv/local/lib/python2.7/site-packages/neo4django/neo4jclient.py",
line 179, in gremlin_tx
return self.gremlin(script, tx=True, **params) File "/home/alan/workspace/neowiki/venv/local/lib/python2.7/site-packages/neo4django/neo4jclient.py",
line 168, in gremlin
params) File "/home/alan/workspace/neowiki/venv/local/lib/python2.7/site-packages/neo4django/neo4jclient.py",
line 153, in send_script
script_rv = ext.execute_script(s, params=params, **execute_kwargs) File
"/home/alan/workspace/neowiki/venv/local/lib/python2.7/site-packages/neo4jrestclient/client.py",
line 1960, in call
raise StatusException(response.status, msg) neo4jrestclient.request.StatusException: Error [400]: Bad Request. Bad
request syntax or unsupported method. Invalid data sent:
org.codehaus.groovy.control.MultipleCompilationErrorsException:
startup failed: Script4.groovy: 94: unable to resolve class
org.neo4j.cypher.javacompat.CypherParser # line 94, column 1.
import org.neo4j.cypher.javacompat.CypherParser ^
1 error
My requirements.txt includes:
-e git://github.com/scholrly/neo4django.git#eefdf6a122fdbe26c62b6563f9ff6b30a4de2f93#egg=neo4django-dev
neo4jrestclient==1.7.0
Any help is greatly appreciated!
From what I can see, your installation is fine. The problem is the version of Neo4j.
So far, we only support Neo4j 1.6-1.8. While I try to support all major releases in use, I typically extend support for milestones closer to a general release. For example, I didn't extend support to Neo4j 1.8 until it hit milestone 6.
Is there a particular reason you're using 1.9M01, or would the most recent stable release (1.8GA) suffice?

django: can't adapt error when importing data from postgres database

I'm having strange error with installing fixture from dumped data. I am using psycopg2, and django1.1.1
silver:probsbox oleg$ python manage.py loaddata /Users/oleg/probs.json
Installing json fixture '/Users/oleg/probs' from '/Users/oleg/probs'.
Problem installing fixture '/Users/oleg/probs.json': Traceback (most recent call last):
File "/opt/local/lib/python2.5/site-packages/django/core/management/commands/loaddata.py", line 153, in handle
obj.save()
File "/opt/local/lib/python2.5/site-packages/django/core/serializers/base.py", line 163, in save
models.Model.save_base(self.object, raw=True)
File "/opt/local/lib/python2.5/site-packages/django/db/models/base.py", line 495, in save_base
result = manager._insert(values, return_id=update_pk)
File "/opt/local/lib/python2.5/site-packages/django/db/models/manager.py", line 177, in _insert
return insert_query(self.model, values, **kwargs)
File "/opt/local/lib/python2.5/site-packages/django/db/models/query.py", line 1087, in insert_query
return query.execute_sql(return_id)
File "/opt/local/lib/python2.5/site-packages/django/db/models/sql/subqueries.py", line 320, in execute_sql
cursor = super(InsertQuery, self).execute_sql(None)
File "/opt/local/lib/python2.5/site-packages/django/db/models/sql/query.py", line 2369, in execute_sql
cursor.execute(sql, params)
File "/opt/local/lib/python2.5/site-packages/django/db/backends/util.py", line 19, in execute
return self.cursor.execute(sql, params)
ProgrammingError: can't adapt
First I've checked similar issues on internet. This one seemed to be very related: http://code.djangoproject.com/ticket/5996, as my data has many non ASCII symbols
But actually I've checked my django installation and it's ok there
Could you advice what is wrong
====
Continued investigation after added print statement as suggested by the first answer. Log looks this way:
silver:probsbox oleg$ python manage.py loaddata /Users/oleg/probs.json
Installing json fixture '/Users/oleg/probs' from '/Users/oleg/probs'.
<DeserializedObject: Novice>
<DeserializedObject: Junior>
<DeserializedObject: Chess enthusiast>
<DeserializedObject: Experienced player >
<DeserializedObject: Smart player>
Problem installing fixture '/Users/oleg/probs.json': Traceback (most recent call last):
File "/opt/local/lib/python2.5/site-packages/django/core/management/commands/loaddata.py", line 153, in handle
print obj
File "/opt/local/lib/python2.5/site-packages/django/core/serializers/base.py", line 155, in __repr__
return "<DeserializedObject: %s>" % smart_str(self.object)
File "/opt/local/lib/python2.5/site-packages/django/utils/encoding.py", line 107, in smart_str
return str(s)
File "/opt/local/lib/python2.5/site-packages/django/db/models/base.py", line 335, in __str__
return force_unicode(self).encode('utf-8')
File "/opt/local/lib/python2.5/site-packages/django/utils/encoding.py", line 71, in force_unicode
s = unicode(s)
File "/Users/oleg/Sites/probsbox/registration/models.py", line 58, in __unicode__
return u"%s's profile" %(self.user.username)
File "/opt/local/lib/python2.5/site-packages/django/db/models/fields/related.py", line 257, in __get__
rel_obj = QuerySet(self.field.rel.to).get(**params)
File "/opt/local/lib/python2.5/site-packages/django/db/models/query.py", line 305, in get
% self.model._meta.object_name)
DoesNotExist: User matching query does not exist.
silver:probsbox oleg$
Error from very last comment
<DeserializedObject: qwert2000's profile>
Problem installing fixture '/Users/oleg/probs.json': Traceback (most recent call last):
File "/opt/local/lib/python2.5/site-packages/django/core/management/commands/loaddata.py", line 154, in handle
obj.save()
File "/opt/local/lib/python2.5/site-packages/django/core/serializers/base.py", line 163, in save
models.Model.save_base(self.object, raw=True)
File "/opt/local/lib/python2.5/site-packages/django/db/models/base.py", line 495, in save_base
result = manager._insert(values, return_id=update_pk)
File "/opt/local/lib/python2.5/site-packages/django/db/models/manager.py", line 177, in _insert
return insert_query(self.model, values, **kwargs)
File "/opt/local/lib/python2.5/site-packages/django/db/models/query.py", line 1087, in insert_query
return query.execute_sql(return_id)
File "/opt/local/lib/python2.5/site-packages/django/db/models/sql/subqueries.py", line 320, in execute_sql
cursor = super(InsertQuery, self).execute_sql(None)
File "/opt/local/lib/python2.5/site-packages/django/db/models/sql/query.py", line 2369, in execute_sql
cursor.execute(sql, params)
File "/opt/local/lib/python2.5/site-packages/django/db/backends/util.py", line 19, in execute
return self.cursor.execute(sql, params)
ProgrammingError: can't adapt
The can't adapt error is raised by psycopg2 when it receives an data type that it doesn't know how to translate into a value for a SQL statement. For example, if you accidentally pass a list, say, for a value that is supposed to be an integer, psycopg2 will raise this can't adapt error.
The faq.txt document that ships with the source distribution of psycopg2 explains it this way:
Why does !cursor.execute() raise the exception can't adapt?
Psycopg converts Python objects in a SQL string representation by looking
at the object class. The exception is raised when you are trying to pass
as query parameter an object for which there is no adapter registered for
its class. See :ref:adapting-new-types for informations.
Probably your best first-pass at finding the offending value is to run loaddata in fully verbose mode: python manage.py loaddata --verbosity=2 /Users/oleg/probs.json
Well, I was hoping loaddata verbosity would work and I wouldn't have to confess that I've never found an elegant way of debugging adaptation errors with django's loaddata. In the past, I've resorted to inserting print statements in django's loaddata function so that I can see the values being deserialized when the error occurs. I've edited django/core/management/loaddata.py. Look of obj.save() in the handle() function. I hope this confession inspires someone to share a better solution :-)
Ok, I ended copying dump from my database, and restoring it locally without python...