Use django-autocompletelight package -  
https://django-autocomplete-light.readthedocs.org/en/master/

Asif

-----Original Message-----
From: BangPypers 
[mailto:bangpypers-bounces+asif.jamadar=rezayat....@python.org] On Behalf Of 
Nikhileshkumar Ikhar
Sent: Wednesday, December 09, 2015 6:13 PM
To: Bangalore Python Users Group - India
Subject: Re: [BangPypers] Fwd: Regarding Forms : "ModelMultipleChoiceField"

With 5000 choices, it is not a good design from performance n usability
point of view.

How many times these choices will be accessed? If frequently you have to
add them in cache n use ajax calls.
If not so frequently then you can go ahead with current design.

But i would suggest to use ajax calls to narrow down the list of choices.
You can built a trie structure or something similar at backbend.
At front end user will type some characters and you will fire ajax calls to
get relevant results and show it to users.

Nikhil
On 09-Dec-2015 2:31 pm, "Kishan Mehta" <kishanmeh...@gmail.com> wrote:

> Hi All,
>
> I am working on custom admin interface form generation. I want to display
> big amount of results (around 5k) as multiple choice field in django form.
>
> I want to add search functionality and paginate my following
> "ModelMultipleChoiceField" field of django form
>
> so that results can be selected easily. Is it the right approch?
> Here is my forms.py
>
>
>
>
>
>
>
>
>
> *class ScheduledTestForm(forms.ModelForm):        tags =
> forms.ModelMultipleChoiceField(queryset=Tag.objects.all())       class
> Meta:        model = Test        exclude = ['pita_id', 'challenge',
> 'test_template']*
>
> Here is my template.html :(partial code) :
>
>
> {% block nav-global %}{% endblock %}
> {% block content %}
>
>
>
> *<form action="." method="post">        {% csrf_token %}        {{
> form.as_p  }}        <input type="submit" value="Submit" />*
>     </form>
> {% endblock %}
> _______________________________________________
> BangPypers mailing list
> BangPypers@python.org
> https://mail.python.org/mailman/listinfo/bangpypers
>
_______________________________________________
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers
_______________________________________________
BangPypers mailing list
BangPypers@python.org
https://mail.python.org/mailman/listinfo/bangpypers

Reply via email to