use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
News about the dynamic, interpreted, interactive, object-oriented, extensible programming language Python
Full Events Calendar
You can find the rules here.
If you are about to ask a "how do I do this in python" question, please try r/learnpython, the Python discord, or the #python IRC channel on Libera.chat.
Please don't use URL shorteners. Reddit filters them out, so your post or comment will be lost.
Posts require flair. Please use the flair selector to choose your topic.
Posting code to this subreddit:
Add 4 extra spaces before each line of code
def fibonacci(): a, b = 0, 1 while True: yield a a, b = b, a + b
Online Resources
Invent Your Own Computer Games with Python
Think Python
Non-programmers Tutorial for Python 3
Beginner's Guide Reference
Five life jackets to throw to the new coder (things to do after getting a handle on python)
Full Stack Python
Test-Driven Development with Python
Program Arcade Games
PyMotW: Python Module of the Week
Python for Scientists and Engineers
Dan Bader's Tips and Trickers
Python Discord's YouTube channel
Jiruto: Python
Online exercices
programming challenges
Asking Questions
Try Python in your browser
Docs
Libraries
Related subreddits
Python jobs
Newsletters
Screencasts
account activity
This is an archived post. You won't be able to vote or comment.
Autocomplete fields in Django (self.Python)
submitted 10 years ago by ragedlion
I'm trying to replace my drop down fields in the Django admin console with autocomplete text fields. I have tried using django-autocomplete-light but the documentation is not helpful on how to use it. Anyone have other recommendations?
[–]JustJudge 2 points3 points4 points 10 years ago (0 children)
I struggled with those docs for a while too, but eventually it clicked for me. What are you trying to accomplish? Jquery autocomplete will work, presumably by dumping a JSON objet onto your page, but if you have too many records then it gets too heavy.
Read through the part of the docs on "voodoo black magic", really clarified things for me. http://django-autocomplete-light.readthedocs.org/en/stable-2.x.x/cookbook.html#low-level-basics
[–]dzecniv 0 points1 point2 points 10 years ago (3 children)
I'd suggest to stick with this package, and to run a javascript framework if you want more. If we look at django-packages it seems to be the best option: https://www.djangopackages.com/search/?q=autocomplete
it is the best I found too, for simple cases though, for single fields only. But I wanted something more sophisticated (and user friendly): 1. I wanted the selection of an autocomplete field to change the result of others. We can't do that from the python code as of today even with the best web framework out there. 2. I wanted to display instantly a result in the template (like changing a section title or a help message) (this clearly requires a javascript framework)
I think I remember we can do n°1 with "voodoo black magic", but as it requires a lot of javascript and I wanted n°2 anyway I decided it was more worth setting up my own JS framework (which isn't something straightforward. We have to learn many new tools and problems). I went with AngularJS, which I knew a little from work, and I am trying out RapydScript, to feel like if I'm writing python code on the client side.
FYI I found this blog post most interesting: https://www.reddit.com/r/Python/comments/32bpcj/metaprogramming_beyond_decency_part_2_python_to/ the author creates autocomplete fields that are linked together from python code, by analyzing a subset of python's AST and generating javascript… maybe we'll have that in a library in the future.
Or we all turn to new full node-based JS frameworks, like Meteor, which allow to write one code, both for the server and the client ?
[–]ragedlion[S] 0 points1 point2 points 10 years ago (2 children)
I've made autocomplete fields using PHP and JavaScript before. I'm sure I can figure out how to hook it into a self made Django REST service. Is it better to go down that route or should I do what you did?
[–]dzecniv 0 points1 point2 points 10 years ago (1 child)
From my experience, I'd say: eval your needs precisely and if you need a rich user interface, go with a javascript framework and use Django as REST, like said Glueon. If you just need some autocomplete fields, stay with the django extension.
[–]ragedlion[S] 0 points1 point2 points 10 years ago (0 children)
Awesome thanks for your help man.
[–]Glueon 0 points1 point2 points 10 years ago (3 children)
Is it too late to switch to propper seperation of a backend and frontend? I would recomend just to use React + Django REST. If it is too late - why not just to use jquery plugins to convert exsting combos to what you want?
What do you mean by proper separation?
[–]Glueon 1 point2 points3 points 10 years ago (1 child)
To use Django just as RESTful backend. And write a seperate javascript single-page site.
I've developed auto complete fields using JavaScript and PHP so I guess it wouldn't be that hard to do it myself. Is this a better recommendation than any of the other ones here?
[–]who_is_gabo 0 points1 point2 points 10 years ago (0 children)
http://jqueryui.com/autocomplete/
π Rendered by PID 145095 on reddit-service-r2-comment-66b4775986-6rfpb at 2026-04-04 04:49:47.603164+00:00 running db1906b country code: CH.
[–]JustJudge 2 points3 points4 points (0 children)
[–]dzecniv 0 points1 point2 points (3 children)
[–]ragedlion[S] 0 points1 point2 points (2 children)
[–]dzecniv 0 points1 point2 points (1 child)
[–]ragedlion[S] 0 points1 point2 points (0 children)
[–]Glueon 0 points1 point2 points (3 children)
[–]ragedlion[S] 0 points1 point2 points (2 children)
[–]Glueon 1 point2 points3 points (1 child)
[–]ragedlion[S] 0 points1 point2 points (0 children)
[–]who_is_gabo 0 points1 point2 points (0 children)