I have upgraded to django 1.0 beta or the latest version for my
development machine. And faced IntegrityError when i delete a record
with few related records. This problem do not happen before django 1.0

A Product model and a Part model, which is a 1-to-many relationship,
(a Product can have multiple Parts). The Parts has an InlineAdmin in
Product admin, so that i can modify the Part records which belongs to
it on the same admin page.

I have created Product record, with some Part records (which belong to
the Product record) and save, it is OK.
When i delete the product record i have created. The django admin
shows a confirmation page. Say that:

Are you sure?
Are you sure you want to delete the product "My Product"? All of the
following related items will be deleted:

I answered: "Yes, I'm Sure", but it shows 1451, 'Cannot delete or
update a parent row: a foreign key constraint fails'

Do you know why? my models.py and admin.py are as follows:

------------------
models.py
------------------
class Product(models.Model):
        name = models.CharField(max_length=100)

class Part(models.Model):
        product = models.ForeignKey(product)
        name = models.CharField(max_length=100)

------------------
admin.py
------------------
class PartInline(admin.TabularInline):
        model = Part

class ProductAdmin(admin.ModelAdmin):
        inlines = [PartInline]

admin.site.register(Product, ProductAdmin)
--~--~---------~--~----~------------~-------~--~----~
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