Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9169865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:56:15+00:00 2026-06-17T15:56:15+00:00

I am trying to understand how to use django-autocomplete-light for an existing project. This

  • 0

I am trying to understand how to use django-autocomplete-light for an existing project. This seems like a good autocomplete solution for django for which I am already using normal ModelChoiceFields.

So, let’s say that I have a Model named MyModel that has an id and a name. What I’d like to know is the simplest possible way of creating a form widget that would provide me the same functionality with

mymodel = forms.ModelChoiceField(  required=True, queryset=ships.models.Authority.objects.all() , ) 

so I’d be able to add that widget to any form I wanted in order to select instances of MyModel without using selec.t

What are the required steps to have that ? I’ve already added ‘autocomplete_light’ to INSTALLED_APPS and

url(r'autocomplete/', include('autocomplete_light.urls')),

to urls.py and

import autocomplete_light
autocomplete_light.autodiscover()

before

admin.autodiscover()

however I am getting confused with what to do next 🙁

Please don’t point me in the documentation I’ve already read it thoroughly.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T15:56:16+00:00Added an answer on June 17, 2026 at 3:56 pm

    Select widget is default for ModelChoiceField

    This form field does not specify a widget, so the select widget should be used by default with:

    mymodel = forms.ModelChoiceField(
                    required=True,
                    queryset=ships.models.Authority.objects.all(),
              ) 
    

    This is why you see a select field instead of an autocomplete.

    Did you read django docs about using widgets ?

    Use autocomplete_light.ChoiceWidget instead

    All you have to do is specify the widget:

    mymodel = forms.ModelChoiceField(
                required=True,
                queryset=ships.models.Authority.objects.all(),
                widget=autocomplete_light.ChoiceWidget('AutocompleteName')
              ) 
    

    If you don’t know what is the name of the autocomplete, login as staff and open http://yoursite/autocomplete/.

    Ensure that you have jquery properly loaded and that autocomplete-light’s staticfiles are loaded too !

    Alternatives

    FTR: another way is possible, using autocomplete_light.modelform_factory using shortcuts like autocomplete_light.modelform_factory or autocomplete_light.get_widgets_dict. API docs are passable but it does not beat reading the source code.

    All in all, I think the easiest for you is using the get_widgets_dict shortcut if you are using a ModelForm.

    Hidden docs

    You might not have found the cookbook because it is a work in progress in the docs_rewrite branch, but the second part of “High level basics” provides several examples of using the widget.

    I know that the docs have a problem, hence the docs_rewrite branch. Right now I’m focusing on improving mobile support.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am learning Django and I am trying to understand the use of models.py
This is my first project in django and im using photologue for gallery, which
I'm trying to understand how to use Passive View correctly. It seems to me
I am trying to use django-sitetree but I don't understand how to do step
I am trying to understand the below use of a lambda expression. This code
I'm pretty new to Django and right now I'm trying to understand the use
I am trying to understand how it's possible to use http://code.google.com/p/django-simple-captcha/ with django comments.
I´m trying to understand and use the Picasa Api, I´m using this example https://developers.google.com/picasa-web/docs/2.0/developers_guide_java?hl=nl-NL
I'm trying to understand how to use nested routes. My code: App.Router.map(function() { this.route(site,
I'm trying to understand how to use firebug to debug my Javascript. So I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.