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

#727 wip, added tests #729

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

benzkji
Copy link

@benzkji benzkji commented Apr 20, 2024

I've added tests, but don't know how I could add migrations for the new models needed for testing.

@benzkji
Copy link
Author

benzkji commented Apr 20, 2024

  • Added migration with poetry run django-admin makemigrations tests --settings=modeltranslation.tests.settings.
  • Had to add Pillow to dev dependencies, was not able to run makemigrations otherwise.

A few tests (5) fail now, because the test object cannot be deleted anymore ;)

@benzkji
Copy link
Author

benzkji commented Apr 21, 2024

I can't get it to work properly. See my latest commit, that's how it's supposed to be setup?

@benzkji benzkji changed the title #727 wip, added tests, without migrations #727 wip, added tests Apr 22, 2024
@benzkji
Copy link
Author

benzkji commented Jan 6, 2025

Any time/input, here?

For me, it's a use case of modeltranslation - having an abstract base class with a foreign key, and having multiple classes that inherit from it, each using translated fields. As it's in the tests:
https://github.com/deschler/django-modeltranslation/pull/729/files#diff-a11e634034d805d4ce683d541f9b181dfc9e2d56beb6036134368586fba097d6R98

It's really deep in the Django core, I still think I was right here: "Django thinks that the two fields of the child models belong to the same model, and then trigger the TypeError / Cannot combine queries on two different base models error, during the update query for the "models.SET_NULL" foreign keys. That's what I think, I might be wrong."

So it's somewhere in Metaclasse, wherever hidden deep?

@last-partizan
Copy link
Collaborator

Hello!

Last time we stopped at the step where it fails just as it should fail, e.q. "issue is present and we have correct test-case for reproducing it". Right?

As for what to do next, I don't know.

Have you tried removing TranslationOptions here?

class SecondSetNullForeignKeyModelTranslationOptions(SetNullForeignKeyBaseModelTranslationOptions, TranslationOptions):
    fields = [
        "translated22",
    ]

If removing it helps, great. If it doesn't help - try digging deeper, and ask questions. I'll try to share my knowledge, but this project is fairly complex and I just doing maintenance here, I'm not the original creator.

@benzkji
Copy link
Author

benzkji commented Jan 7, 2025

Thanks @last-partizan thanks. I will dig then :)

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

Successfully merging this pull request may close these issues.

2 participants