-
Notifications
You must be signed in to change notification settings - Fork 575
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
from_model throws ResolutionFailed for models with user-specified autoincrement id fields #3978
Comments
It's been five years since I looked into that, but iirc the idea was to avoid automatically generating values for auto-incrementing index fields. If you want that to be generated anyway, you can pass e.g. If that does in fact solve your problem, I'd prefer to keep the existing behavior because being too 'helpful' has gone wrong here in the past. |
Sorry, I did a bad job explaining. I actually have the opposite problem...I want hypothesis to not generate a strategy for my id column, but I don't think I can do that. Because I defined the autoid column myself, instead of letting django do it, the "is this a field I should skip" check fails (because A simplified version of the model: class Group(models.Model):
groupid = models.AutoField(primary_key=True) |
Oh, I see - yeah, this seems like something I'd be happy to accept a PR for. I guess we could do something like |
This was a fun one...it turns out The cleanest fix seemed to me to be to add in a |
closed by #3984 |
I'm using hypothesis to test a django rest framework api, and I get a
ResolutionFailed
exception when trying to usefrom_model()
to generate model instances for my tests. It looks like this is happening because my model's primary key is amodels.AutoField
that I specified, not one that django created automatically.I'm pretty sure this line is what's tripping me up. Looking at the change that introduced
from_model()
, I don't see that samefield.auto_created
check in its predecessor,models()
.Does anyone know why that check was added? Would a PR to remove it be accepted?
The text was updated successfully, but these errors were encountered: