Hi all,
This is possibly a Django-2.2.18 related problem, but I thought I'd see if anyone else has experienced this and had a workaround.
I recently updated my website to Mezzanine 5.0.0a1 and Django 2.2.18, and after some reasonably thorough local testing, deployed it to the live website.
One of my fellow admins discovered something odd, which I've now confirmed on both local and deployed sites.
At the top of an Admin change list page, there's the standard
action drop down (usually containing 'Delete selected <Model
name>'). This is useful when you want to select some objects
and delete them, but otherwise I've not customised it for any of
the standard Mezzanine/Cartridge models I use.
What's now odd is that if you hit the 'Save' button at the bottom
of the object list, a generic prompt pops up saying 'Please select
an item in the list' pointing to this action drop down.
After some research, I discovered the following:
a) this pop up message is generic from HTML5, for a <select> form element that has the 'required' attribute: https://www.w3schools.com/TAGS/att_select_required.asp
b) this 'required' attribute is being added to the <select> element when the page is rendered, but only when DEBUG=False. That is, on my local development with DEBUG=True, the select element is not required (and Save works fine), but if I modify my local settings and set DEBUG=False, then required is forced on this element, and I get the same pop up as seen on the deployed server.
I've tried digging into the Django code to try and find out
what's happening to render this field, but it seems to be fairly
benign:
grapelli-safe template that renders the action drop down:
https://github.com/stephenmcd/grappelli-safe/blob/master/grappelli_safe/templates/admin/actions.html#L3
django code that is the action form:
https://github.com/django/django/blob/2.2.18/django/contrib/admin/helpers.py#L20
I'm not sure where the ChoiceField is being forced to
required=True when DEBUG=False, nor how I can override this.
Any one got any ideas? Have you noticed this on your own
deployments using Mezzanine 5.0.0a1?
Thanks for any help,
Seeya. Danny.
Have you tried checking one of the forms used in the templates?
You can check there if required is explicitly declared.
Example:
selection = forms.CharField(
required=True,
widget=forms.ChoiceField(attrs={"class": "form-control", "type": "text", }),
)
--
You received this message because you are subscribed to the Google Groups "Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mezzanine-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mezzanine-users/a46283a7-99de-02ad-628f-26b80459403b%40gmail.com.