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

DjangoModelFactory using another app model instead of the one it supposed to use #918

Closed
avarajar opened this issue Apr 13, 2022 · 1 comment

Comments

@avarajar
Copy link

Description

I have two models with the same name but under different apps. music.Album and music_v2.album so the issue is that when DjangoModelFactory is trying to populate the data is using the wrong model

Model / Factory code
class AlbumFactory(DjangoModelFactory):
    artist = SubFactory(ArtistFactory)
    name = Faker('catch_phrase')

    class Meta:
        model = 'music.Album'

Notes

It says this when is populating the data.. Is using music_v2 model instead of music
Screen Shot 2022-04-13 at 1 59 12 PM

@francoisfreitag
Copy link
Member

Did you have both apps installed in Django?
The logic to resolve the model asks the Django apps registry for the app and model name, so if they are registered correctly, FactoryBoy should be using the correct model.

If you find that it is not the case, please reopen, with some code to reproduce the issue.

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