Using valid HTML 4.01 Strictly with Django

I found a similar question here , but I am looking for more general solutions.

As it is now, when Django generates anykind HTML for you (this happens mainly when creating forms), it uses default self-closing tags, i.e. <br />instead of <br>. <br />XHTML is valid, and I think HTML5 is as well, but it is not valid HTML4.

Is there any clean way to override this? Or is it better to write django sites in XHTML or HTML5?

+3
source share
2 answers

There was a whole series of discussions about this when development for 1.2 began, offering a number of proposed solutions, but not a common forward path was agreed.

But see the Simon Willison Django-HTML project for one possible solution.

+1
source

You can completely rewrite django's HTML output for you. EG: for a form, you can:

  • choose between the output using the table, p or li using the as_xxx property .
  • print the label by label , choosing tag wrappers.
  • use widget to determine how part of the form will be printed in HTML.

Of course, you need new forms for this, and there to use Django 1.X.

+1

Source: https://habr.com/ru/post/1735792/


All Articles