Saturday, April 23, 2016

Re: Django apparently can't handle that error.

Stephen, I am using Django 1.9.5, PostgreSQL 9.3
I do not know, maybe the order of the apps may be interfering in the way Django sorts the commands to be sent to the postgresql.

INSTALLED_APPS = [
'core', # here: Account, Log
'myapp', # here: Car, CarLog

What is happening is that post_delete is trying to create a log for an account that does not exist. The exception doesn't works.
This seems to be a bug.

Em sábado, 23 de abril de 2016 18:28:08 UTC-3, Stephen Butler escreveu:
Sorry, I did miss that.

I created a quick test project in 1.9 and ran your sample. It works fine for me. The delete() returns that it deleted 4 objects: the Account, Car, Log, and CarLog. There's something else in your project that is causing the error.

On Sat, Apr 23, 2016 at 3:42 PM, Neto <paulosou...@gmail.com> wrote:
Stephen, CarLog is inheriting Log.


Em sábado, 23 de abril de 2016 17:14:57 UTC-3, Stephen Butler escreveu:
Look a little closer at the error message:

Error:
insert or update on table "myapp_log" violates foreign key constraint "myapp_log_account_id_6ea8d7a6_fk_myapp_account_id"  DETAIL:  Key (account_id)=(11) is not present in table "myapp_account".
It's happening this error rather than the exception.

The table is myapp_log, not myapp_carlog. The error isn't in the post_delete signal you're showing up. Do you have a post_delete for Account objects?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/92e72312-5678-428b-ad7f-360ad911ceaa%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/02b1ab5b-d7e3-4df2-9738-9c1636e931c5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment