I do not know the reason for that nor I have found any documentation about
it.
See Select.render_option for the field qith queryset longer than 100 rows.
--
Ticket URL: <https://code.djangoproject.com/ticket/26396>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
Can you please give steps to reproduce this?
--
Ticket URL: <https://code.djangoproject.com/ticket/26396#comment:1>
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>
Comment (by timgraham):
Can you reproduce with the `django.db.backends.mysql` backend? If not, I
guess the problem is in `mysql.connector.django` which is provided by
Oracle, not the Django team. If so, can you provide the models for your
test or (ideally) a test for Djanog's test suite? There are some tests for
`ModelChoiceField` in `model_forms/tests.py`.
--
Ticket URL: <https://code.djangoproject.com/ticket/26396#comment:3>
* status: new => closed
* resolution: => wontfix
Comment:
Works fine with `django.db.backends.mysql`.
--
Ticket URL: <https://code.djangoproject.com/ticket/26396#comment:4>
* resolution: wontfix => invalid
--
Ticket URL: <https://code.djangoproject.com/ticket/26396#comment:5>