Wednesday, June 30, 2010

does QuerySet delete delete the objects by their primary key?

Hi,

I did a query on an object using their "non" primary keys such that:

a = Topic.objects.filter(topic='Politics')
topic is not a primary key. suppose topicID is primary key.

When I run:

a.delete()

the SQL that is executed is:

DELETE FROM 'Topic' WHERE topicID in (1)

my problem is a little harder than that in the sense my table has
multiple keys so suppose its topicID and course is the primary key
together but since topicID is '1' for both the objects returned by the
filter it tries to be smart and randomly picks what it "thinks" is the
primary key and deletes based on that.

First off I hate the fact that Django doesn't support multiple primary
keys... Any suggestions to delete objects using their fields that are
passed in or do I have to override the delete function to be able to
do this?

Cheers,
Nathan.

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment