Found the answer.
I used crispy like this:
{{ form|crispy }}

*But We should use like this to get form helper effect:*

{% crispy form %}

On Wednesday, March 20, 2019 at 7:02:31 PM UTC+3:30, Mohammad Etemaddar 
wrote:

> Here is my model form which is rendered by crispy.
> When I change the layout, ordering, or adding elements, has no effect on 
> rendered form.
>
> Do you see any problem in the code?
>
> Thank you
>
>
> class FactoryForm(forms.ModelForm):
> class Meta:
> model = Factory
> fields = ('name','field', 'description', 'manager','province','city',
> 'address','phone_number','logo')
>
> province = forms.ModelChoiceField(queryset=Province.objects.all())
>
> def __init__(self, *args, **kwargs):
> super(FactoryForm, self).__init__(*args, **kwargs)
>
> self.helper = FormHelper(self)
> self.helper.form_tag = False
> self.helper.disable_csrf = True
>
> self.helper.layout = Layout(
> Fieldset(
> 'Legend',
> 'name', 'field', 'description', 'manager', 'province', 'city', 'address', 
> 'phone_number',
> HTML("""<img class="img-responsive" src="{{ MEDIA_URL }}{{ 
> form.logo.value }}">"""),
> 'logo',
> )
> )
>
> if self.instance.name:
> self.fields['province'].initial = self.instance.city.province
> self.fields['city'].queryset = City.objects.filter(province=self
> .instance.city.province)
>
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c9df2370-dfce-4b63-aa50-9766d06c71b4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to