Hello,
I need some help with the code after the IntegrityError exception.

<snip>
s = Student.objects.get(pk=student_id)

if request.method == 'POST':
  form = ChangeForm(request.POST)
  if form.is_valid():
        try:
          form.save()
          request.user.message_set.create(message="Your request has been
submitted...")
          return HttpResponseRedirect(reverse(student, args=(s.id,)))
        except IntegrityError:
          request.user.message_set.create(message="Can't do that!")
          return HttpResponseRedirect(reverse(student, args=(s.id,)))
</snip>

This code throws:
Exception Type: ProgrammingError at /new_change/45/
Exception Value: current transaction is aborted, commands ignored
until end of transaction block

Commenting out the 'message create' line, the code runs. If I leave
it, Django attempts to insert my message string into the database.

params
[11, "Can't do that!"]
self
<django.db.backends.util.CursorDebugWrapper object at 0x1931850>
sql
'INSERT INTO "auth_message" ("user_id","message") VALUES (11,\'Can
\'\'t do that!\')'

I'm sure I'm just coding this wrong. Anyone help me out?

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to