> Den 12. nov. 2015 kl. 14.41 skrev Erik Cederstrand 
> <erik+li...@cederstrand.dk>:
> 
> Hi Ezequeil,
> 
> Thanks for the explanation! This worked, but defining a new widget from 
> scratch meant that I lost the other helpful attributes (length, class etc.) 
> that the admin adds for me. Instead, in the DRY spirit, I opted to just add 
> this one extra attribute. Here's the relevant code:
> 
> class MyAdminForm(forms.ModelForm):
>    def __init__(self, *args, **kwargs):
>        super().__init__(*args, **kwargs)
>        self.fields['username'].widget.attrs['autocomplete'] = 'off'

Just to follow up, this didn't actually work for me, I just thought so. 
Apparently, all major browsers have go to great lengths to ignore any attempts 
to disable autocomplete, and any suggestions to actually get it working 
involves hidden fields, custom javascript and all sorts of hoops and tricks 
(see e.g. 
http://stackoverflow.com/questions/22661977/disabling-safari-autofill-on-usernames-and-passwords).

So it seems I'm stuck with either disabling autocomplete entirely in my 
browser, or having the username for my LDAP server overwritten with 'erik' 
every time I open that form. Infuriating.

Erik

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2A4E02D8-0813-4FA0-9804-BA1015C76472%40cederstrand.dk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to