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

Issue with foreign keys defined in "app.ModelName" format in abstract base classes #730

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

Conversation

benzkji
Copy link

@benzkji benzkji commented Apr 21, 2024

Somehow the field.model is not yet a class, but still a string, in this particular case.

Tried a fix (modeltranslation/fields.py), but issue seems deeper, I guess it should really just not be a string?

This PR just shows the problem.

@benzkji benzkji marked this pull request as ready for review April 21, 2024 11:31
@benzkji
Copy link
Author

benzkji commented Apr 21, 2024

This issue arose during #727 and #729

@benzkji benzkji changed the title showcase for issue with foreign keys defined in "app.ModelName" format in abstract base classes Showcase for issue with foreign keys defined in "app.ModelName" format in abstract base classes Apr 21, 2024
@benzkji benzkji changed the title Showcase for issue with foreign keys defined in "app.ModelName" format in abstract base classes Issue with foreign keys defined in "app.ModelName" format in abstract base classes Apr 21, 2024
@last-partizan
Copy link
Collaborator

Probably, yes. We expect there a model, not a string.

@last-partizan last-partizan marked this pull request as draft April 21, 2024 13:40
@benzkji
Copy link
Author

benzkji commented Apr 21, 2024

But in this edge case, it is a string. Nothing special, or do you see something special in my example code? Defining foreign key field's models as strings is supported and sometimes necessary, in Django, so shouldn't it be with modeltranslation?

@last-partizan
Copy link
Collaborator

That looks like error, or maybe we're accessing it at the wrong time (during init).

If you look at any other foreign key, field.model is a model class, even if it's string in the definition.

@benzkji
Copy link
Author

benzkji commented Apr 22, 2024

Agreed. Hard to tackle down. It's really only when in an abstract base class.

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