wq / django-natural-keys

Enhanced support for natural keys in Django and Django REST Framework.
MIT License
39 stars 11 forks source link

Django 3.2 `BigAutoField` IDs break natural keys for models with a single unique field #16

Closed marcosox closed 3 years ago

marcosox commented 3 years ago

From Django 3.2 new models are now generated by default with BigAutoField IDs instead of AutoField, as written in the release notes.

This breaks the support for natural keys when using a single unique field in the model, because this check inside get_natural_key_def() now fails.

I can write a PR which checks for BigAutoField too, but I don't know if someone can come up with a more generalized method.

marcosox commented 3 years ago

See #17 for the proposed fix

sheppard commented 3 years ago

Thanks, this fix is good for now.