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 8125165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:43:29+00:00 2026-06-06T06:43:29+00:00

can anybody post the simplest possible example for django-ajax-selects ? Just one model with

  • 0

can anybody post the simplest possible example for django-ajax-selects ? Just one model with a field and a form that can be used to select instances of this model based on that field (not in admin but in a user form).

I tried reading the documentation of the project but found it very difficult to understand… Also, I was not able to make the Example App work (coudln’t find out what is a Label ???) 🙁

Also, if you believe that there is an easiest solution than django-ajax-selects please tell me.

Thank you!

  • 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-06T06:43:32+00:00Added an answer on June 6, 2026 at 6:43 am

    Here is a simple example (from the example on github but not tested):

    models.py:

    class Person(models.Model):
        name = models.CharField(blank=True, max_length=100)
        email = models.EmailField()
    
        def __unicode__(self):
            return self.name
    
    
    class Group(models.Model):
        name = models.CharField(max_length=200,unique=True)
        members = models.ManyToManyField(Person,blank=True,help_text="Enter text to search for and add each member of the group.")
    
        def __unicode__(self):
            return self.name
    

    forms.py:

    class GroupForm(ModelForm):
    
        class Meta:
            model = Group
    
        members  = make_ajax_field(Release,'members','person')
    

    lookups.py:

    class PersonLookup(LookupChannel):
    
        model = Person
    
        def get_query(self,q,request):
            return Person.objects.filter(name__icontains=q).order_by('name')
    
        def get_result(self,obj):
            return obj.name
    
        def format_match(self,obj):
            return self.format_item_display(obj)
    
        def format_item_display(self,obj):
            return u"%s" % escape(obj.name)
    

    settings.py:

    AJAX_LOOKUP_CHANNELS = {
         'person' : ('example.lookups', 'PersonLookup'),
    }
    

    views.py:

    class Create(generic.CreateView):
        template_name = "create.html"
        form_class = GroupForm
        success_url = 'create'
    
    create = Create.as_view()
    

    urls.py:

    urlpatterns = patterns('',
        url(r'^create',  view='views.create',name='create'),
        url(r'^ajax_lookup/(?P<channel>[-\w]+)$', 'ajax_select.views.ajax_lookup', name = 'ajax_lookup'),
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anybody point me to a simple example about how to implement form based
Can anybody give me a little advice please? I have a string, for example
Can anybody post a link to a comparison chart, or even to a duplicated
can anybody gimme any help about how to overwrite a model entry. i have
Can anybody tell me why is the record not inserted? This is my one
Can anybody help me make this work, the idea is , if a post,
Could anybody post here some code how can I read word by word from
Can anybody help me how to invoke the post method provided here. I am
How can I call the same action using ajax from different pages? type: 'POST',
Can anybody post the Java version of this VB.NET code? Public Function FetchDoc(Of T

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.