Уже мертвый час я ломаю голову над проблемой.
Почему в первом случае отображается SECURITY_WITHOUT
, а во втором - display
?В конце концов, все идентично ...
В общем, в обоих случаях должна отображаться переведенная фраза с django.po
.Но как этого добиться?...
models.py
CONFIRMATION_WITHOUT = 'display1'
CONFIRMATION_WITH = 'display2' #`display2` showed
CONFIRMATION_CHOICES = (
(CONFIRMATION_WITHOUT, _('Display1')),
(CONFIRMATION_WITH, _('Display2')),
)
SECURITY_WITHOUT = 'Display1'
SECURITY_WITH = 'Display2' #`SECURITY_WITH` showed
SECURITY_CHOICES = (
('SECURITY_WITHOUT', _('Display1')),
('SECURITY_WITH', _('Display2')),
)
income_proof = models.CharField(_('proof'), max_length=255, choices=CONFIRMATION_CHOICES, default=CONFIRMATION_WITHOUT)
security = models.CharField(_('security'), max_length=255, choices=SECURITY_CHOICES, default=SECURITY_WITHOUT)
forms.py
security = forms.ModelChoiceField(queryset=CreditPayment.objects.values_list('security', flat=True).distinct(), widget=forms.Select(attrs={'class': "selectpicker form-control", 'title':_("Security")}))
income_proof = forms.ModelChoiceField(queryset=CreditPayment.objects.values_list('income_proof', flat=True).distinct(), widget=forms.Select(attrs={'class': 'selectpicker form-control', 'title':_("Income proof")}))
template
{{ big_form.security }}
{{ big_form.income_proof }}
html
<div class="form-group">
<div class="dropdown bootstrap-select form-control show">
<select class="selectpicker form-control" id="id_big-security" name="big-security" tabindex="-98">
<option value="" selected="selected">---------</option>
<option value="SECURITY_WITHOUT">SECURITY_WITHOUT</option>
</select>
<button type="button" class="btn dropdown-toggle bs-placeholder btn-light" data-toggle="dropdown" role="button" data-id="id_big-security" title="---------" aria-expanded="true"><div class="filter-option"><div class="filter-option-inner"><div class="filter-option-inner-inner">---------</div></div> </div></button>
<div class="dropdown-menu show" role="combobox" style="max-height: 394px; overflow: hidden; min-height: 0px; position: absolute; transform: translate3d(0px, 61px, 0px); top: 0px; left: 0px; will-change: transform;" x-placement="bottom-start"><div class="inner show" role="listbox" aria-expanded="true" tabindex="-1" style="max-height: 376px; overflow-y: auto; min-height: 0px;"><ul class="dropdown-menu inner show"><li class="selected active"><a role="option" class="dropdown-item selected active" aria-disabled="false" tabindex="0" aria-selected="true"><span class=" bs-ok-default check-mark"></span><span class="text">---------</span></a></li><li><a role="option" class="dropdown-item" aria-disabled="false" tabindex="0" aria-selected="false"><span class=" bs-ok-default check-mark"></span><span class="text">SECURITY_WITHOUT</span></a></li></ul></div></div></div>
</div>
<div class="form-group">
<div class="dropdown bootstrap-select form-control">
<select class="selectpicker form-control" id="id_big-income_proof" name="big-income_proof" tabindex="-98">
<option class="bs-title-option" value=""></option>
<option value="display">display</option>
</select>
<button type="button" class="btn dropdown-toggle bs-placeholder btn-light" data-toggle="dropdown" role="button" data-id="id_big-income_proof"><div class="filter-option"><div class="filter-option-inner"><div class="filter-option-inner-inner"></div></div> </div></button>
<div class="dropdown-menu " role="combobox"><div class="inner show" role="listbox" aria-expanded="false" tabindex="-1"><ul class="dropdown-menu inner show"></ul></div></div></div>
</div>