#26396: ModelChoiceField shows only 100 choices
----------------------------+--------------------------------------
     Reporter:  pkaczynski  |                    Owner:  nobody
         Type:  Bug         |                   Status:  new
    Component:  Forms       |                  Version:  1.8
     Severity:  Normal      |               Resolution:
     Keywords:              |             Triage Stage:  Unreviewed
    Has patch:  0           |      Needs documentation:  0
  Needs tests:  0           |  Patch needs improvement:  0
Easy pickings:  0           |                    UI/UX:  0
----------------------------+--------------------------------------

Comment (by pkaczynski):

 Sure. I checked more throughly and I found that it is a problem with mysql
 database. Here's my conf:
 {{{#!python
 DATABASES = {
     'default': {
         'ENGINE': 'mysql.connector.django',
         'NAME': '***',
         'USER': 'energyportal',
         'PASSWORD': '****',
         'OPTIONS': {
           'autocommit': True,
         },
         'TEST': {
             'NAME': 'energyportal_test',
         },
     }
 }
 }}}

 And here's test code:

 {{{#!python
 class DjangoTicket26396(TestCase):

     def test_example(self):
         from django.forms.models import ModelChoiceField
         from django.forms.widgets import Select
         from energycore.models.retail import Contract
         from energycore.models import Client
         client = Client.objects.create(
             name='test',
             short_name='test',
         )
         invoice_category = InvoiceCategory.objects.create(
             symbol='TST', type='sell', description='test'
         )
         for i in range(1315):
             Contract.objects.create(side=client, number='123',
                                     payment_due_days=1,
                                     invoice_category=invoice_category,
 revise_invoice_category=invoice_category)
         f = ModelChoiceField(queryset=Contract.objects.all(),
 widget=Select)
         self.assertEquals(len(f.choices), 1316)
         self.assertEquals(len([e for e in f.choices]), 1316)
 }}}

 The only thing is that it doesn't work (i.e. test passses) for plain
 models like "User" - I tried. However for my models it doesn't. It seems
 like foreign key issue.

--
Ticket URL: <https://code.djangoproject.com/ticket/26396#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.b8c717925e554889bf1186987464902b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to