Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translated foreign key in an abstract base class: foreign key instances cannot be deleted. #727

Open
benzkji opened this issue Apr 19, 2024 · 5 comments

Comments

@benzkji
Copy link

benzkji commented Apr 19, 2024

I have a abstract Link base class, used for my Teaser and ContentNav models. The base class has a field file, that is then translated in each of the real classes. The file field is a FileField from django-filer, so basically a ForeignKey.

When I try to delete a File instance, I get a TypeError / Cannot combine queries on two different base models. from django itself. The file field is configured as on_delete=models.SET_NULL, and as far as I can tell, the error happens because django wants to update all the needed foreign key fields, but somehow gets two querysets of different models (the two translated above) to combine and update. Why exactly is very hard to tell.

Has this happend before? I'll try to write a test, to rebuild the error - it currently happens in an old project, that was updated several times.

@last-partizan
Copy link
Collaborator

I'm not sure.

Do you get this error when you disable django-modeltranslation?

@benzkji
Copy link
Author

benzkji commented Apr 20, 2024

I'm not sure, will try.

@benzkji
Copy link
Author

benzkji commented Apr 20, 2024

Indeed, if I disable translation on one of the translated models, deletion is possible. I'll try to write a test, seems like a very edge case.

benzkji added a commit to benzkji/django-modeltranslation that referenced this issue Apr 20, 2024
benzkji added a commit to benzkji/django-modeltranslation that referenced this issue Apr 20, 2024
@benzkji
Copy link
Author

benzkji commented Apr 20, 2024

please see PR, need directions for adding migrations :)

benzkji added a commit to benzkji/django-modeltranslation that referenced this issue Apr 20, 2024
@benzkji
Copy link
Author

benzkji commented Apr 20, 2024

The PR: #729

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants