Django, unique form field identifiers

I have a simple Django form:

class CommentForm(forms.Form): comment = forms.CharField(max_length=2000, required=True) post_id = forms.CharField(max_length=2000, widget=forms.HiddenInput, required=True) parent_id = forms.CharField(max_length=2000, widget=forms.HiddenInput, required=True) 

Now I want to print this form several times on my page - I do this through the template tag, so a new form is created every time. The problem is that I get the same identifier for all fields.

I know about the prefix, but I don’t want to change the names of the fields, because for all forms there is one handler, only for setting unique identifiers.

So my question is:

  • Is there a way to make Django set unique identifiers if I want to display the form several times without changing the field names?
  • If not, is there a way to prevent Django from displaying identifiers at all?
+7
source share
1 answer

You can control how automatic identifiers are generated with the auto_id parameter when creating a new instance of this form

Take a look here (find auto_id ):

http://docs.djangoproject.com/en/dev/ref/forms/api/#configuring-html-label-tags

+11
source

All Articles