Monday, October 29, 2018

Re: Many to Many field in ModelForm - with tens of thousands of records

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+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/36ebab2d-7440-40bc-b5e9-a4a2897dcd3a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment