On Mon, Feb 26, 2018 at 9:16 AM, Alan <[email protected]> wrote:

> Hi there,
>
> I have this in my forms.py:
>
> class SubmissionForm(forms.Form):
>
>
>     molecule_file = 
> forms.FileField(validators=[FileExtensionValidator(settings.CONTENT_TYPES),
> file_size], help_text="Required: Select a PDB, MDL or MOL2 file")
>
> But I am failing to make it work in my submit.html template. Currently, I
> am "hacking" with:
>
> <p title="Required: Select a PDB, MDL or MOL2 file."><label>
> {{form.molecule_file.label}}</label>{{ form.molecule_file }}</p>
>
> That will show the tooltip "Required: Sel..." if mouse pause over this
> field in the browser, but this is silly, I wish I could use something like:
>
> <p title={{form.molecule_file.help_text}}><label>{{form.
> molecule_file.label}}</label>{{ form.molecule_file }}</p>
>
> But that is not working, neither any combination I tried with .title etc.
>
> Any suggestion would be very much appreciated.
>
> Many thanks in advance,
>
> Alan
>

Alan,

The use of "help_text" in a template is shown here:
https://docs.djangoproject.com/en/2.0/topics/forms/#looping-over-the-form-s-fields

That is an example of how you should render a form field "manually". You
may also try seeing the output of {{ form.as_p }} and then tweak it to your
needs (you can use that in whatever tooltip wrapper - like bootstrap or
other css frameworks).

HTH!

>
> --
> I'll cycle across Britain in 2018 for a charity, would you consider
> supporting my cause? http://uk.virginmoneygiving.com/AlanSilva
> Many thanks!
> --
> Alan Wilter SOUSA da SILVA, DSc
> Senior Bioinformatician, UniProt
> European Bioinformatics Institute (EMBL-EBI)
> European Molecular Biology Laboratory
> Wellcome Trust Genome Campus
> Hinxton
> Cambridge CB10 1SD
> United Kingdom
> Tel: +44 (0)1223 494588
>
> --
> 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/CAEznbzmoK07JfXPp_MOvmYFe84a%3D5YiBQMEFJOtUsUzpjPjTGg%
> 40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAEznbzmoK07JfXPp_MOvmYFe84a%3D5YiBQMEFJOtUsUzpjPjTGg%40mail.gmail.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 [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/CA%2BFDnhJROhWhC8mMx2ycsVX2m37rRyaXR_Mg3EALJfZhFFskJQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to