Hi Sanjay,
On Monday, October 29, 2018 at 5:09:50 PM UTC+5:30, Sanjay Bhangar wrote:
-- Thanks for the prompt response and the approach.
That seems to be an efficient approach - would look into auto-complete.
Thanks.
On Monday, October 29, 2018 at 5:09:50 PM UTC+5:30, Sanjay Bhangar wrote:
My recommendation would be to use a bit of Javascript to implement an
"autocomplete" to fetch records via AJAX as the user types (with
perhaps a minimum of 3 characters or so), so you only ever fetch a
subset of records and don't overload your template.
You can find quite a few 3rd party libraries that should be able to
aid in setting up this behaviour, see:
https://djangopackages.org/grids/g/auto-complete/ - unfortunately, I
can't recommend a particular one right now - but most should have
integrations for the django admin / django forms with Many2Many or
ForeignKey fields.
Hope that helps,
Sanjay
On Mon, Oct 29, 2018 at 5:01 PM Web Architect <pina...@gmail.com> wrote:
>
> Would also add that the server CPU usage was hitting 100% due to the template loading issue.
>
> On Monday, October 29, 2018 at 4:48:54 PM UTC+5:30, Web Architect wrote:
>>
>> Hi,
>>
>> We are using django 1.11 for our ecommerce site.
>>
>> We are facing an issue with modelform and many to many field in it as follows:
>>
>> Lets say there are two models:
>>
>> class A(models.Model):
>> c = models.CharField()
>>
>> class B(models.Model):
>> a = models.ManyToManyField('A')
>>
>> Now if I define a modelform:
>>
>> class MF(models.ModelForm):
>> class Meta:
>> model = B
>> fields = [a,]
>>
>> We are using django widget tweaks to render the fields in MF. Now if there are tens of thousands of records in A, the MF form rendering causes the page to hang as the widget will try to show the whole set of tens of thousands of records option for field a.
>>
>> Hence, would appreciate if anyone could suggest a smart solution wherein the above issue is taken care of.
>>
>> Thanks.
>>
>>
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com .
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users .
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/36ebab2d- .7440-40bc-b5e9-a4a2897dcd3a% 40googlegroups.com
> For more options, visit https://groups.google.com/d/optout .
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e7590f4d-2658-4c8a-bfba-02a5d64cbb12%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment