[BangPypers] Fwd: Regarding Forms : "ModelMultipleChoiceField"

Nikhileshkumar Ikhar nikhil.ikhar at gmail.com
Wed Dec 9 10:12:37 EST 2015


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" <kishanmehta3 at 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 at python.org
> https://mail.python.org/mailman/listinfo/bangpypers
>


More information about the BangPypers mailing list