Hi all! I have a delete that isn't working properly. It deletes more than 1 register when it shouldn't because I'm specifying the primary key in the filter. The class file is this: class UserInstrument(models.Model): user_name = models.CharField(primary_key=True, maxlength=60) instrument_name = models.CharField(blank=False, maxlength=60) permission = models.TextField(blank=True) def __str__(self): string="user_name: "+self.user_name+"; instr_name: "+self.instrument_name+"; permission: "+self.permission return string class Meta: db_table = 'User_instrument' unique_together = (("user_name", "instrument_name"),) In the view function I'm doing this: UserInstrument.objects.filter(user_name__exact=username, instrument_name__exact=itemid).delete()
If I do this: number=UserInstrument.objects.filter(user_name__exact=username, instrument_name__exact=itemid).count() assert False In the error page number=1 which means that there is only one register with that user_name and that instrument_name. I don't understand why this is happening. It should delete only one register and instead it's deleting all records with the user_name=username. I went directly to MySQL and did select * from User_instrument where user_name='abc' and instrument_name='ABC'; these were the user_name and instrument_name which were being used, and only one register came out. Oh and another detail, in the MySQL table, the primary key is the user_name and the instrument_name together. Does anyone know why this is happening?? Is there a way in which I can see the SQL commands Django is sending to MySQL? Thanks for your time. Ana --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---