question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Upgrading from 1.6.1 to 1.7.* - forms don't work

See original GitHub issue
  • Package version: 1.7.2 (or 1.7.0 or 1.7.1)
  • Django version: 1.11.16
  • Python version: 3.5.2
  • Template pack: (Optional)

Description:

  • We upgraded Speedy Net from django-crispy-forms==1.6.1 to django-crispy-forms==1.7.2

  • We didn’t expect anything to change.

  • Our contact form stopped working in all 4 websites.

Preferably also include:

  • Example Django Crispy Forms code

The tag is {% crispy form %} on feedback_form.html

  • Screenshots

  • With django-crispy-forms==1.6.1: 2019-01-08_1949_speedy_net_-_contact_form_working

  • With django-crispy-forms==1.7.2:

2019-01-08_1947_speedy_net_-_contact_form_not_working

  • Actual HTML generated

There is no <textarea ... in the HTML with 1.7.0 up to 1.7.2.

  • Expected HTML

There is <textarea ... in the HTML with 1.6.1.

I can’t paste HTML into this issue, I tried.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:39

github_iconTop GitHub Comments

1reaction
narocommented, Apr 11, 2019

I would like to reopen this issue. It’s very easy to reproduce for me.

Let’s have a ModelForm and add a few custom fields to it

class MyModel(Model):
    field1 = models.CharField()

class MyForm(ModelForm):
    extra_field = forms.CharField()
   
    class Meta:
        model = MyModel
        fields = ('field1', 'extra_field')

If you render this form in Crispy Forms < 1.7.0 it works and renders both fields If you render this form in Crispy Forms >= 1.7.0 it renders field1 only

The reason is commit https://github.com/django-crispy-forms/django-crispy-forms/commit/6b93e8a362422db8fe54aa731319c7cbc39990ba which broke it. The ‘extra_field’ is neither required or hidden so it depends on render_unmentioned_fields which defaults to False. Since the field is mentioned in Meta.fields, it should be rendered. See also docs/form_helper.rst

By default django-crispy-forms renders the layout specified if it exists strictly, which means it only renders what the layout mentions unless your form has Meta.fields and Meta.exclude defined, in that case, it uses them. If you want to render unmentioned fields (all form fields), for example, if you are worried about forgetting mentioning them you have to set this property to True. It defaults to False.

I wonder why @ghinch committed this at all. If fields are mentioned in Meta.fields they should be unconditionally rendered, shouldn’t they?

1reaction
mostafagafercommented, Jan 9, 2019

and if I imported : from crispy_forms.helper import FormHelper

in the forms.py it will yield another error :

File “D:\installed_apps\python\lib\site-packages\crispy_forms\helper.py”, line 4, in <module> from django.core.urlresolvers import reverse, NoReverseMatch ModuleNotFoundError: No module named ‘django.core.urlresolvers’

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot update from 1.6.1 to 1.7.0 - Get Help
The software update plugin gives an error when trying to update from 1.6.1 to 1.7.0. This happens on both of my two octoprints...
Read more >
1.6.1.17 to 1.7.x Problem with 1 click upgrade module
Hello,. You will not be able to upgrade from PrestaShop 1.6 to 1.7 using the standard update module in 1 click, this will...
Read more >
How to upgrade to to version 1.9.1 from a 1.5.0, 1.6.1 or 1.7 ...
Issue. Does the entire SBO system need to be upgraded to 1.5.0.171xx, 1.6.2.12xxx or 1.7.2.111xx before upgrading to 1.9.1 if the network ...
Read more >
Upgrading 1.6.5 to 1.7
Before you begin, go to global configuration and on the server tab and in the Database Settings area find the database table prefix...
Read more >
Upgrading VIVO to release 1.7
This document contains instructions on how to upgrade your installation of VIVO from Version 1.6 (or 1.6.1, or 1.6.2) to Version 1.7.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found