In one of my views, I've got an answers = Answer .objects .select_related (depth=2).filter(question__promotion__slug__exact=promotion) .
Answer has a ForeignKey to Question, which in turn has a ForeignKey to Promotion, which has a SlugField. When I run this query from the shell and call response['answertest'] = answers[0].correct , I get a proper True/False. However, when run from the view's request, I get the traceback below. When changing the query to answers = Answer.objects.select_related(depth=2).all() I don't get this problem, however that defeats the purpose of filtering. My current theory is that there's something wrong with filtering across doubly-spanned relationships, however it does work when run from the shell. The reason I'm trying to do this is because currently I have some nested loops in my promotion view that cause tons of SQL queries on the inner loops between Questions and Answers. I'm going to use instead a {% regroup answers by question as questions %} in my template code; which works with the all() query so I know the regroup isn't the problem. Traceback: > Environment: > > Request Method: GET > Request URL: http://localhost:8000/us/product/whatsnew/test/ > Django Version: 1.0-final-SVN-unknown > Python Version: 2.5.1 > Installed Applications: > ['django.contrib.auth', > 'django.contrib.contenttypes', > 'django.contrib.sessions', > 'django.contrib.sites', > 'retailu.learn', > 'retailu.product', > 'retailu.storytime', > 'retailu.stattrack', > 'retailu.index', > 'retailu.whatevermap', > 'retailu.plano', > 'retailu.assettracker', > 'django.contrib.admin', > 'django.contrib.admindocs', > 'django.contrib.databrowse', > 'django.contrib.markup', > 'mobileadmin', > 'django_evolution', > 'rosetta', > 'debug_toolbar'] > Installed Middleware: > ('django.middleware.cache.UpdateCacheMiddleware', > 'django.middleware.common.CommonMiddleware', > 'django.contrib.sessions.middleware.SessionMiddleware', > 'django.contrib.auth.middleware.AuthenticationMiddleware', > 'django.middleware.doc.XViewMiddleware', > 'django.middleware.locale.LocaleMiddleware', > 'django.middleware.http.ConditionalGetMiddleware', > 'django.middleware.gzip.GZipMiddleware', > 'django.middleware.cache.FetchFromCacheMiddleware') > > > Traceback: > File "/Library/Python/2.5/site-packages/django/core/handlers/ > base.py" in get_response > 86. response = callback(request, *callback_args, > **callback_kwargs) > File "/Library/WebServer/retailu/../retailu/product/views.py" in > promotion > 45. response['answertest'] = answers[0].correct > File "/Library/Python/2.5/site-packages/django/db/models/query.py" > in __getitem__ > 232. return list(qs)[0] > File "/Library/Python/2.5/site-packages/django/db/models/query.py" > in __len__ > 156. self._result_cache.extend(list(self._iter)) > File "/Library/Python/2.5/site-packages/django/db/models/query.py" > in iterator > 269. for row in self.query.results_iter(): > File "/Library/Python/2.5/site-packages/django/db/models/sql/ > query.py" in results_iter > 206. for rows in self.execute_sql(MULTI): > File "/Library/Python/2.5/site-packages/django/db/models/sql/ > query.py" in execute_sql > 1700. cursor.execute(sql, params) > File "/Library/Python/2.5/site-packages/django/db/backends/util.py" > in execute > 19. return self.cursor.execute(sql, params) > File "/Library/Python/2.5/site-packages/django/db/backends/sqlite3/ > base.py" in execute > 167. return Database.Cursor.execute(self, query, params) > > Exception Type: InterfaceError at /us/product/whatsnew/test/ > Exception Value: Error binding parameter 0 - probably unsupported > type. > -- Cortland Klein <[EMAIL PROTECTED]> +1 408 506 9791 http://pixelcort.com/ 2260 California Street #13 Mountain View, CA, USA 94040 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---