У меня довольно странная ошибка после обновления до Django 1.5 .. когда я получаю доступ к моей панели инструментов ClientDetailView с панелью отладки Django, я получаю следующее ошибка:«Текущая транзакция Django прерывается, команды игнорируются до конца транзакционного блока» только после обновления до 1.5
Traceback:
File "/Users/mirkocrocop/.virtualenvs/upstream_backend/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
187. response = middleware_method(request, response)
File "/Users/mirkocrocop/.virtualenvs/upstream_backend/lib/python2.7/site-packages/debug_toolbar/panels/template.py" in process_response
118. pformat(k(self.request))) for k in get_standard_processors()
File "/Users/mirkocrocop/workspace/upstream_backend/my_auth/context_processors.py" in extended_auth
13. user_groups = [g['name'] for g in tmp]
File "/Users/mirkocrocop/.virtualenvs/upstream_backend/lib/python2.7/site-packages/django/db/models/query.py" in _result_iter
123. self._fill_cache()
File "/Users/mirkocrocop/.virtualenvs/upstream_backend/lib/python2.7/site-packages/django/db/models/query.py" in _fill_cache
927. self._result_cache.append(next(self._iter))
File "/Users/mirkocrocop/.virtualenvs/upstream_backend/lib/python2.7/site-packages/django/db/models/query.py" in iterator
1004. for row in self.query.get_compiler(self.db).results_iter():
File "/Users/mirkocrocop/.virtualenvs/upstream_backend/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in results_iter
775. for rows in self.execute_sql(MULTI):
File "/Users/mirkocrocop/.virtualenvs/upstream_backend/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
840. cursor.execute(sql, params)
Exception Type: InternalError at /clients/5/
Exception Value: current transaction is aborted, commands ignored until end of transaction block
... Я знаю, что иногда я должен отключить его, чтобы увидеть, что реальная ошибка, но теперь, если я деактивировать DDT ошибка исчезает полностью. Он не должен влиять на производственный сервер, но он все еще довольно раздражает.
Вот мнение в вопросе:
class BaseSingleClient(LoginRequiredMixin,
generic.detail.SingleObjectMixin):
def get_context_data(self, **kwargs):
'''
Add the current client object to the context.
This will be used in the template
'''
context = super(BaseSingleClient, self).get_context_data(**kwargs)
try:
self.client = self.kwargs['client_id']
except KeyError, e:
self.client = self.kwargs['pk']
context['client_obj'] = UpstreamClientModel.objects.get(pk=
self.client)
return context
class ClientDetailView(BaseSingleClient, generic.DetailView):
model = UpstreamClientModel
template_name = 'clients/client_detail.html'
И SQL, который выполняется в момент ошибки:
DEBUG (0.004) SELECT "django_session"."session_key", "django_session"."session_data", "django_session"."expire_date" FROM "django_session" WHERE ("django_session"."session_key" = '0ayyigap4sphq5lvtlfy64una45o4id6' AND "django_session"."expire_date" > '2013-05-27 10:38:44.800431+00:00'); args=('0ayyigap4sphq5lvtlfy64una45o4id6', u'2013-05-27 10:38:44.800431+00:00')
DEBUG (0.002) SELECT "my_auth_profile"."id", "my_auth_profile"."password", "my_auth_profile"."last_login", "my_auth_profile"."is_superuser", "my_auth_profile"."username", "my_auth_profile"."first_name", "my_auth_profile"."last_name", "my_auth_profile"."email", "my_auth_profile"."is_staff", "my_auth_profile"."is_active", "my_auth_profile"."date_joined", "my_auth_profile"."cost_hour", "my_auth_profile"."last_activity" FROM "my_auth_profile" WHERE "my_auth_profile"."id" = 3 ; args=(3,)
DEBUG (0.001) SELECT "auth_group"."name" FROM "auth_group" INNER JOIN "my_auth_profile_groups" ON ("auth_group"."id" = "my_auth_profile_groups"."group_id") WHERE "my_auth_profile_groups"."profile_id" = 3 ; args=(3,)
Это где последний запрос приходит от BTW:
my_auth.context_processors.py
def extended_auth(request):
'''
@allowed_user (bool) the user is either a Core team member or an admin.
@user_groups (string) the groups the user belongs to.
'''
is_allowed = False
user_groups = None
if not request.user.is_anonymous():
tmp = request.user.groups.values('name')
user_groups = [g['name'] for g in tmp]
if 'Core' in user_groups or 'Administrator' in user_groups:
is_allowed = True
return {'allowed_user': is_allowed, 'user_groups': user_groups, }
Я включил выполняемые SQL-операторы. Я попробовал их самостоятельно, и они возвращают то, что ожидается ... это что-то еще до этого? –
@ la_f0ka Да, вам нужно найти * первую ошибку в транзакции. Это может помочь вам добавить идентификатор транзакции или backend pid в префикс файла журнала PostgreSQL. –
Удивительно, ... Мне не хватало стола. Что-то послышалось во время миграций и даже не заметил. Идите фигуру. Благодаря! –