2015-08-20 19 views
1

錯誤Django的脆皮形式顯示上述InlineRadios但低於模型等

class TourLead(models.Model): 
    GENDER_CHOICES = (
     ('M', 'Male'), 
     ('F', 'Female'), 
    ) 

    name = models.CharField(max_length=256) 
    gender = models.CharField(max_length=1, choices=GENDER_CHOICES) 
的形式

gender = forms.ChoiceField(widget=forms.RadioSelect(), choices=TourLead.GENDER_CHOICES) 

這裏

是佈局:

Layout(
     Field('name', placeholder='John Doe'), 
     InlineRadios('gender'), 
     # ... 
    ) 

enter image description here

我的問題一世我怎麼能把總是在後輸入?

我已經嘗試了一些CSS:

[id^="error"] { 
    position: absolute; 
    top: 100%; 
    width: 100%; 
} 

但無法弄清楚如何顯示一些一種隔離的(保證金...)後...

enter image description here

回答

0

我已經解決這個指定的自定義模板

InlineRadios('gender', template='radioselect_inline.html'), 

只需複製它並radioselect.htmlsite-packages/...到您的靜態文件夾,並改變「radioselect_inline.html」最後包括對

{% include 'radioselect.html' %} 

radioselect.html移動{% include 'bootstrap3/layout/field_errors_block.html' %}到底像下面

#... 
    {% endfor %} 

    {% include 'bootstrap3/layout/field_errors_block.html' %} 
    {% include 'bootstrap3/layout/help_text.html' %} 
</div> 

此外,在這一刻,你將面對的bug https://github.com/maraujop/django-crispy-forms/issues/361所以簡單地降級到django-crispy-forms==1.4.0,它會工作!