Pregunta

This Stackoverflow post says: W3C has tended towards lowercase for attribute names and values for a while i.e. use something like

<form method="post" />

However, in a Django view, the method name is compared with an uppercase string

if request.method == 'POST': # If the form has been submitted...

Why are the cases mixed up here ? Is the browser converting 'post' to uppercase for Django?

¿Fue útil?

Solución

HTTP method names are case-sensitive, and all registered method names are all-uppercase.

The lowercase spelling in HTML form attributes essentially is a bug in HTML that is impossible to fix due to backwards compatibility reasons.

Otros consejos

Perhaps this is part of the reason : https://stackoverflow.com/a/10766285/781695. Though it doesn't answer the discrepancy between W3C & RFC 3875

RFC 3875 defines the REQUEST_METHOD variable as upper case, so it's okay to rely on it.

The REQUEST_METHOD meta-variable MUST be set to the method which should be used by the script to process the request ...

  REQUEST_METHOD   = method
  method           = "GET" | "POST" | "HEAD" | extension-method
  extension-method = "PUT" | "DELETE" | token

The method is case sensitive.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top