Are you add in setiings.py file
installed_apps = [
.....
'crispy_forms',
]
CRISPY_TEMPLATE_PACK = 'bootstrap4'
then add this in page template you want to render
{% load crispy_forms_tags %}
On Wednesday, 20 March 2019 17:32:31 UTC+2, 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/a23c65c6-6241-4470-a452-2234296cfd00%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.