Why is auto_id not working in my form?

I’m trying to create a Wikipedia-like site and am trying to add a feature that allows users to create their own wiki page. I manage to render the form, but the labels are annoying me and I wish I could get rid of them or, better yet, make them appear inside the fields, such like the “placeholder” in HTML but couldn’t figure out how to

I read this (https://docs.djangoproject.com/en/3.1/ref/forms/api/#ref-forms-api-configuring-label) and tried to use the auto_id=False when I’m using the form constructor:
render(request, “encyclopedia/create.html”, {“form”:PageCreationForm(auto_id=False)})
But it does nothing. There isn’t a error message either. The looks just the same and I don’t know why. What did I get wrong?

If you read the example in that section of the docs, you’ll see that setting auto_id = False does not inhibit the display of the label itself. All it does is prevent the generation of a separate label tag for the label. It generates the label as text within the HTML.

If you don’t want to create a label at all for a field, that’s done in the form on a field-by-field basis. (I’m not aware of any single option to prevent the generation of any labels.) The precise mechanism as to how you would do this is going to depend upon whether you’re creating a Form or a ModelForm.

1 Like