I have a field in a Django model, and I want there to be a small (~20) set of possibilities (which are strings) which can be autocompleted (preferably with django-autocomplete-light, which I am using already) in django-admin. Should I make this a foreign key field and create a model containing just these 20 possibilities? or is there a better way?
Autocomplete a specific set of possibilities in Django-admin
151 Views Asked by Jakob Weisblat At
2
There are 2 best solutions below
0
Guy Gavriely
On
django orm limit should be done something like:
Entry.objects.all()[:5]
so creating a new model for limiting number of results would not make sense.
I've looked at django-autocomplete-light and saw limit_choices here (didn't give it a try.
in any case it should be something like line 77 in this snippet.
I hope this is helpful.
Related Questions in PYTHON
- new thread blocks main thread
- Extracting viewCount & SubscriberCount from YouTube API V3 for a given channel, where channelID does not equal userID
- Display images on Django Template Site
- Difference between list() and dict() with generators
- How can I serialize a numpy array while preserving matrix dimensions?
- Protractor did not run properly when using browser.wait, msg: "Wait timed out after XXXms"
- Why is my program adding int as string (4+7 = 47)?
- store numpy array in mysql
- how to omit the less frequent words from a dictionary in python?
- Update a text file with ( new words+ \n ) after the words is appended into a list
- python how to write list of lists to file
- Removing URL features from tokens in NLTK
- Optimizing for Social Leaderboards
- Python : Get size of string in bytes
- What is the code of the sorted function?
Related Questions in DJANGO
- Display images on Django Template Site
- Protractor did not run properly when using browser.wait, msg: "Wait timed out after XXXms"
- Django invalid literal for int() with base 10:
- Removing URL features from tokens in NLTK
- Django Noob URL to from Root Page to sub Page
- Django Admin tables not displaying correctly
- Django with chartkick
- Django urls.py not rendering correct template
- django form errors before submit
- django admin: custom app_index with context
- Display multiple models in one view in Django
- Unexpected NoReverseMatch error when using include() in urls patterns
- Search for a key in django.core.cache
- Django webapp (on an Apache2 server) hangs indefintely when importing nltk in views.py
- Django flush won't load fixtures
Related Questions in AUTOCOMPLETE
- Wikipedia search box; database vs autocomplete
- jQuery autocomplete display worng search item
- Autocompletion does not work in R terminal inside square brackets
- Msysgit git Bash change of behavior on autocomplete
- Make <a> inside jQuery autocomplete clickable
- Xcode, have delegate method auto-include classes
- Store Locator in google maps, input zip code and display markers on map and sidebar
- AngularJS Autocomplete IE9 Issue
- Display a sql query output in jquery autocomplete
- Use Google Maps API address autocomplete feature without separate field
- Implementing Autocomplete textbox in ASP.NET
- Using Devbridge Autocomplete, is there a way to detect no results?
- Autocomplete Search With Link
- Emacs MELPA auto-complete not working with ESS (R) 15.03
- jquery autocomplete - noSuggestionNotice doesn't work
Related Questions in DJANGO-ADMIN
- django admin: custom app_index with context
- I want to dump data which is received by MQTT broker to the sqlite3 db provided by Django/
- How to add methods to customised search_fields in Django admin.ModelAdmin
- Can't run django-admin startproject mysite (ubuntu, django.core.exceptions.ImproperlyConfigured)
- admin registered staff user can't login django admin, form registered staff user can't
- Change Python Class attribute dynamically
- Proper way to handle custom submit button at django custom model admin add page
- Django admin: add widget link broken
- Make field in admin read only dependent on user
- Change Link in Django Suit
- Passing parameters to inline form in django admin
- How to add filter/search logic to django admin.TabularInline
- Filter property objects by other property in Django (Admin)
- Django BooleanField as radio button but between inline forms
- How to fill value in a limit_choices_to option in OneToOneField for Django Admin?
Related Questions in DJANGO-AUTOCOMPLETE-LIGHT
- django-autocomplete-light django 1.8 custom modelform for admin
- django-autocomplete-light: Forward works fine in admin but returns None when used in template
- Django admin and autocomplete-light - how to override save method
- Fill two other fields of a formset depending on autocomplete selection
- django autocomplete-light template plus sign
- Enter text immediately into box for autocomplete
- Django Autocomplete Light List Object has no Attribute Queryset
- Django app not updating static files in browser
- Django Autocomplete Light Empty Select Box
- Combine django mptt TreeNodeChoiceField with django-autocomplete-light ModelSelect2 widget
- Django Material Autocomplete
- django-autocomplete-light and django-filter Forward Filter Selection
- Autocomplete a specific set of possibilities in Django-admin
- django-autocomplete-light default load a previously saved value?
- Django-Auto-Complete Autocomplete not Registered error
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
The only way to do this is to have a separate model with only those possibilities and to make the field we want to limit into a foreign key field.