> Den 12. nov. 2015 kl. 14.41 skrev Erik Cederstrand
> :
>
> 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.
Great!
If you prefer to write some code and not implement new class. What you
thing to override the *get_form *method on model admin?
https://docs.djangoproject.com/en/1.8/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_form
def get_form(self, request, obj=None, **kwargs):
form =
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:
In html:
Um django you need to create a form for your model and set a field to
username. In this field, set a widget like this:
username = forms.CharField(widget=forms.TextInput(attrs={'autocomplete':
'off'}))
Now you set a form on your model admin, like this example
Hello,
I have a model with a CharField named "username". When I edit a model instance
in the admin, my browser likes to autocomplete the contents of the "username"
field with my username for the Django site, regardless of what was entered
previously.
Is there anything I can do to disable this
5 matches
Mail list logo