-
Notifications
You must be signed in to change notification settings - Fork 150
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
Cachalot breaks loading fixtures with no PK #214
Comments
I'm not sure what you mean by fixture loading. Are you talking about pytest with factory boy? Please provide a reproducible example in addition to the version of cachalot's you're using. Thanks! |
Just loading fixtures during standard Django TestCases, or using loaddata management command. I will need some time to try create a minimum reproducible example (will be away for the next week). It appears to be related to fixtures with FK fields specifying the related model using its Natural Key value (not integer PK) django.core.serializers.base.M2MDeserializationError: (DoesNotExist('Group matching query does not exist.'), ['MY_GROUP_NAME']) However the MY_GROUP_NAME group model is defined in the same fixture file before User model is, and loading just that single fixture file by itself appears to work fine... |
I'm using cachalot 2.5.1 |
Note i am also using diskcache.DjangoCache backend, and updating SUPPORTED_CACHE_BACKENDS to add it in to be allowed |
Interesting. An example isn't necessary. Can you post the full stack trace? If cachalot enabled is causing this, then it might have something to do with us loading your models. Have you tried placing cachalot in your INSTALLED_APPS at the very bottom? |
Still occurs with cachalot at the bottom of INSTALLED_APPS. Here's the stack trace from running a custom management command which just calls loaddata command for every fixture of every app:
It appears its due to the Group fixture entry with name 'GROUP_NAME' not being loaded, but works fine with cachalot disabled. I think it's due to the fixture being defined with pk=null, because setting the pk to a valid number fixes it (but I don't want to define PKs for fixtures which can be identified with Natural Keys) |
Looks like the issue can be recreated by trying to load a fixture which has a model with Natural Key support and no PK specified, and another model with a FK field to the first model, using Natural Key values to refer to the first fixture model. if PK is specified on the first model then it works fine. So it's something about not loading fixtures with no PK properly.
|
@Andrew-Chen-Wang any luck with this? |
Hi @Finndersen i've been swamped with tests and work this last month, so i've been unable to find a time to try and resolve this. I'm not really sure if I'll be able to in the near future either, but this is still on my mind. Apologies in advance. |
No worries, I could perhaps have a crack at it if I find some spare time,
have you got any leads in mind?
…On Mon, 11 Apr 2022, 9:58 pm Andrew Chen Wang, ***@***.***> wrote:
Hi @Finndersen <https://github.com/Finndersen> i've been swamped with
tests and work this last month, so i've been unable to find a time to try
and resolve this. I'm not really sure if I'll be able to in the near future
either, but this is still on my mind. Apologies in advance.
—
Reply to this email directly, view it on GitHub
<#214 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEEJXGNDQ75E3JYJQ5RRE6DVEQHW3ANCNFSM5QIWCFPQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
One thing to note is whether you have the model manager set up correctly (I'm sure you do, but just double checking): https://stackoverflow.com/a/25493071 https://docs.djangoproject.com/en/4.0/topics/serialization/ (model manager portion) |
I'm using django-natural-keys which should be managing all that fine |
I'm using django-natural-keys but also the User model has built in natural
key support
…On Mon, 11 Apr 2022, 10:20 pm Andrew Chen Wang, ***@***.***> wrote:
One thing to note is whether you have the model manager set up correctly
(I'm sure you do, but just double checking):
https://stackoverflow.com/a/25493071
—
Reply to this email directly, view it on GitHub
<#214 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEEJXGJLEFGZM6CILQS7PLLVEQKJNANCNFSM5QIWCFPQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Maybe this is related: #224 |
Cachalot appears to impact fixture loading (for test cases) somehow, I think perhaps for fixtures with no PK specified, or with "pk": null.
Fixture loading works as expected with cachalot disabled.
python3.9, django 3.1.7
The text was updated successfully, but these errors were encountered: