The | crispy filter provides only minimal (though stylish) rendering - if
you want to render all the cool stuff in your helper you need to do {%
crispy form %}.

Andromeda Yelton
LITA Board of Directors, Director-at-Large, 2013-2016
http://andromedayelton.com
@ThatAndromeda


On Wed, May 28, 2014 at 8:43 AM, <9devm...@gmail.com> wrote:

> I want to use CreateView along with crispy-forms generated layout.
> However, it seems that everything I pass to *self.helper* in *forms.py*is 
> ignored. Form renders nicely, but only with fields generated by
> CreateView - all fields passed to *Layout* are missing.
>
> My views.py
>
>> class MyView(CreateView):
>>     form_class = MyForm
>>     model = MyModel
>>
>>     def form_valid(self, form):
>>         pass
>>
>> My forms.py:
>
>> from django.forms import ModelForm, Textareafrom crispy_forms.helper import 
>> FormHelperfrom crispy_forms.layout import Submit, Layoutfrom 
>> crispy_forms.bootstrap import FormActions
>> from .models import MyModel
>> class MyForm(ModelForm):
>>
>>     def __init__(self, *args, **kwargs):
>>         super(MyForm, self).__init__(*args, **kwargs)
>>         self.helper = FormHelper(self)
>>         self.helper.form_method = 'POST'
>>         self.helper.add_input(Submit('submit', 'Submit'))
>>         self.helper.layout = Layout(
>>             FormActions(Submit('BlahBlah', 'BlahBlah', 
>> css_class='btn-primary')))
>>
>>     class Meta:
>>         model = MyModel
>>         fields = ['xxx', 'yyy']
>>
>> My image_form.html:
>
>> {% load crispy_forms_tags %}...<form action="" method="post" 
>> enctype="multipart/form-data">
>>     {% csrf_token %}
>>     {{ form|crispy }}</form>
>>
>> What else should I do to make it work?
>
> --
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/2555778c-3f3f-43b4-8670-80ea8abdd1ba%40googlegroups.com<https://groups.google.com/d/msgid/django-users/2555778c-3f3f-43b4-8670-80ea8abdd1ba%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFE1XCZks3sO_rHtAhOno7%3DGjuoPFsOizFMu6FDSiSGaYLPRCg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to