Working with forms

16 views
Skip to first unread message

Williams Andy Inc

unread,
Jun 15, 2021, 1:53:45 AM6/15/21
to Django users
I would like to know is there any easier way rather than overriding super, how do i add icons into the html input eg to have a key icon on the password field 

without installing any third party app also.

is the best solution to render form in html and pass field values to django? or is there anyway to manipulate django and insert a text between input


django has this
<input type="email" name="email" maxlength="60" required="" id="id_email">


i want to have this
<input type="email" name="email" maxlength="60" required="" id="id_email" <i class="far fa-thumbs-down"></i>>

Lalit Suthar

unread,
Jun 15, 2021, 2:54:12 AM6/15/21
to django...@googlegroups.com
you can try if it can be done with widgets I am not sure
https://docs.djangoproject.com/en/2.2/ref/forms/widgets/

--
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 django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/946421cf-4abf-45cd-b40c-f3639203b43bn%40googlegroups.com.

Williams Andy Inc

unread,
Jun 15, 2021, 3:05:31 AM6/15/21
to django...@googlegroups.com
Thanks am already trying that,   and using that works for adding placeholder, but then it doesn't add a class,  if it could add i class i could use the font awesome unicode which would have been the easiest solution.

Williams Andy Inc

unread,
Jun 15, 2021, 3:11:21 AM6/15/21
to django...@googlegroups.com
class LoginForm(forms.Form):
    username = forms.CharField(
        label="Email or Username",
        widget=forms.TextInput(
            attrs={
                "class""fas fa-user",
                "placeholder""f007 Username or Email",
            }
        ),
    ) the class is not showing up but the placeholder shows up without the f007

Williams Andy Inc

unread,
Jun 15, 2021, 3:28:32 AM6/15/21
to django...@googlegroups.com
for now reason its now showing up thanks.   i guess i needed to do hard refresh with f5 although i was using {% now "U" %}
Reply all
Reply to author
Forward
0 new messages