-
-
Notifications
You must be signed in to change notification settings - Fork 81
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
autocomplete_fields feature? #133
Comments
I solved this. One has to write a custom I'm keeping this issue open though as I suspect that either of the following options would help other users:
SolutionI've based the following solution on these links:
|
Edit: I misspelled |
First, thanks for the package, looking really great! I've tested a few features that worked quite well, but I have a particular problem:
Several of my models refer with a ForeignKey to a geo-database that has ~350,000 entries. I've let
django-cruds-adminlte
auto-create all CRUD pages. Whenever I'm trying to load a create/update page of a model that references the foreign key to the geo-database, the connection times out. I have had this problem before with the default django-admin page and it was caused by the model page trying to load all 350,000 entries into the select (see e.g. this StackOverflow). I'm suspecting something similar is happening here.For the default admin page, this can be fixed by adding the
autocomplete_fields
attribute to the respectiveModelAdmin
, which tells the ModelAdmin that a particular field is to be searched asynchronously, and the way it is to be searched is defined in theModelAdmin
of the referencedModel
.Here's an example for the models:
Using these models to auto-generate CRUDS, the create-page of
Institution
times out.Here's how this is solved in the default admin-framework:
Which basically tells django "If a user wants to add a city to an institution, do not load all geoname-values in the select, rather do an Ajax request to the
Geoname
-table which is searched in the fieldsname
and decreasingly order the search results by the fieldpopulation
. Also, paginate the returned list".Is there a way to achieve this using
django-cruds-adminlte
? I've searched the documentation and the github-issues but could not find anything to achieve this.Cheers
Edit: Forgot 'population' entry in
Model
definition.The text was updated successfully, but these errors were encountered: