I'm trying to delete a but when deleting a IntegrityError: Update or Delete "auth_user" foreign key barrier on table "source_id_refs_id_5b69e09fc6161c2a" "core_unfollowing" on the table violates the description:. Key (id) = (6439) is still referenced from the table "core_unfollowing" What is the deal? Associated It's really awkward. Here are some things I'll try: First of all, did you update the database schema after adding I think there is more to a database engine related error than this of Django. If you are 100% positive This is the way that I will take. Also, check whether it is with a specific user or every user, check the reference hanging in the unfollowing table. There may also be an old table that is used and it is giving you problems. I will focus directly on the research with the database and a SQL client and after that I have been able to work it out there, I hope it can help a little bit. . / P> Good luck! user object in a Django app, but I When deleting
users ,
IntegrityError in a related object. Related object looks like this:
class follow (models.model): source = models.ForeignKey (user, related_name = 'unfollowings_by') target = models.ForeignKey (user, related_name = ' Unfollowings_of ') created_on = models.DateTimeField (auto_now_add = true)
user , I receive an error like the following:
user has been removed, then unfollowing related
items should not be automatically removed? For what it's worth, I added a clear
on_delete = models.CASCADE for both
Unfollowing.source and
Unfollowing.target (even if it is worth it That's the default) and I still get the same error
on_delete = models.CASCADE . If not, then there will be no effect on this. You can double check that CASCADE removed dashing database schema directly from Django, by not detecting it.
delete on CASCADE, then auth_user is active in the table and related tables, then you can try to delete a user directly from your SQL client. If this works, and the same user bothers you with Django (or a similar user, given the fact that you have erased one earlier), try dumping the SQL query that Django is doing And repeat it with your SQL client.
No comments:
Post a Comment