You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I believe there is a bug in 'render' function of 'ForeignKeySearchInput' class in admin/widgets.py file. When it creates the url for 'search_path', it should look at the other side of the relationship, because of the way new 'foreignkey_autocomplete' url resolver is added to the admin site in 'get_urls' function of 'ForeignKeyAutocompleteAdmin' class in admin/__init__.py file.
So, in 'render' function of 'ForeignKeySearchInput' class, the code should look something like this:
The way it is now, the inline lookup will not work in general case. It will only work if the model corresponding to the 'to' side of relationship is independently registered on admin site by using ForeignKeyAutocompleteAdmin, too. The bug probably dates back to version 1.6.0.
P.S.: While writing this post, I realized that the workaround would probably be to just derive all the required models on the admin site using 'ForeignKeyAutocompleteAdmin' rather than 'ModelAdmin'. :)
The text was updated successfully, but these errors were encountered:
Hello,
I believe there is a bug in 'render' function of 'ForeignKeySearchInput' class in
admin/widgets.py
file. When it creates the url for 'search_path', it should look at the other side of the relationship, because of the way new 'foreignkey_autocomplete' url resolver is added to the admin site in 'get_urls' function of 'ForeignKeyAutocompleteAdmin' class inadmin/__init__.py
file.So, in 'render' function of 'ForeignKeySearchInput' class, the code should look something like this:
The way it is now, the inline lookup will not work in general case. It will only work if the model corresponding to the 'to' side of relationship is independently registered on admin site by using ForeignKeyAutocompleteAdmin, too. The bug probably dates back to version 1.6.0.
P.S.: While writing this post, I realized that the workaround would probably be to just derive all the required models on the admin site using 'ForeignKeyAutocompleteAdmin' rather than 'ModelAdmin'. :)
The text was updated successfully, but these errors were encountered: