-
Notifications
You must be signed in to change notification settings - Fork 467
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
Exception when using models having primary key names different from 'id' #413
Comments
Even with the fix suggested above the SQL query will fail if the primary key is not an integer, because the value isn't quoted. |
The change to |
Basically in the fix, the only change is replacing "id" with the actual primary_key name of the model. which should fix the reported bug. Any other issues such as reported by rhunwicks is from my opinion not related to this reported bug. |
Closing in favor of PR #417, please join the discussion there. It tests non-id non-numeric id. @rhunwicks |
Could you try with 2.2.0rc1 which was released yesterday ? Thanks. |
Hi, I had the non-id primary key issue with 2.1.1 (was using CharField(16)) and it is fixed after "sudo pip install -U --pre django-autocomplete-light" upgrading to 2.2.0rc2 |
To reproduce the issue, add a custom primary_key field to the FkModel test model
FkModelId = models.AutoField('ID', primary_key=True, editable=False)
Following exception is thrown when adding new values to this model
The problem is the statement
in the method order_choices of autocomplete_light/autocomplete/model.py
It is assumed the primary key name is id
To fix the issue, change the above statement in:
Now use the model primary_key name, which is "id" by default
The text was updated successfully, but these errors were encountered: