attribute required and error XML

18 views
Skip to first unread message

chun974

unread,
Feb 28, 2017, 1:47:11 PM2/28/17
to Django users
Hi all,
I have  an problem. When I use the django library  form, It create an attribute "required" for an input. But when I look on my explorer (firefox or chrome or IE) i have a XML error.
"XML parsing error: malformed".

this is my code :
"
class LoginForm(forms.Form):
email = forms.EmailField(label='Courriel :')
password = forms.CharField(label='Mot de passe :',
widget = forms.PasswordInput)
def clean(self):
cleaned_data = super (LoginForm,self).clean()
email = cleaned_data.get("email")
password = cleaned_data.get("password")
if email and password:
if password != 'bob' or email != 'b...@bob.fr' :
raise forms.ValidationError("Adresse de courriel ou mot de passe erroné.")
return cleaned_data
"

this is my déclaration for XML and doctype :
"
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr"> "

I can put "required=False" and it's OK, but I want that my input is required (required=True it's not OK)
XML don't accept that required attribute is alone, whithout "= someting".

If someone has had this problem?

Django 1.10
Firefox last update

ludovic coues

unread,
Mar 1, 2017, 4:53:54 AM3/1/17
to django...@googlegroups.com
I can't answer on your issue exactly, but <!DOCTYPE html> is not an XML doctype. It's the html5 doctype which as far as I know is SGML and not XML.

Try removing the line starting with <?XML and see if it fix your error.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8cb6a10b-fc89-4f9a-814e-a905ea9eef6b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

chun974

unread,
Mar 2, 2017, 9:49:36 AM3/2/17
to Django users
Thanks, ludovic coues,
I have find the solution. I used eclipse whith django. In the setting.py I have modify (DEFAULT_CONTENT_TYPE='application/xhtml+xml') to (DEFAULT_CONTENT_TYPE='text/html'). It's OK with this. You're right!!
Thanks :) !
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages