Monday, October 29, 2018

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

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/2b3be3a1-e0a6-4c73-8c69-d7a314885ab3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment