Vous n'êtes pas identifié(e).
Bonjour,
je suis entrain de faire un formulaire mais ça ne s'affiche pas.
voici mon code views.py
from django.http import HttpResponse
from django.shortcuts import render_to_response, redirect
from django import forms
from django.forms.fields import ChoiceField, MultipleChoiceField
from django.forms.widgets import RadioSelect ,CheckboxSelectMultiple
from django.template.context import RequestContext
from django.forms.widgets import Input
class Html5EmailInput(Input):
input_type = 'email'
class login(forms.Form):
login = forms.CharField(max_length=30)
password = forms.CharField(max_length=50, widget=forms.PasswordInput())
def login(request):
return render_to_response('login.html', {'login' :login},context_instance=RequestContext(request))
class ContactForm(forms.Form):
name = forms.CharField(max_length=30)
firstname = forms.CharField(max_length=30)
login = forms.CharField(max_length=30)
email = forms.EmailField(max_length=50, widget=Html5EmailInput())
town = forms.CharField(max_length=10)
sex=forms.ChoiceField(
choices = ((u"MALE", u"Male"), (u"FEMALE", u"Female"))
)
password = forms.CharField(max_length=50, widget=forms.PasswordInput())
specialities=forms.ChoiceField(
choices = ((u"AUTRE", u"Autre"), (u"LIVREE", u"livre"),
(u"lecture", u"lecture"), (u"ecriture", u"ecriture"),
(u"danse", u"danse"), (u"chant", u"chant"),
)
def clean_password(self):
password = self.cleaned_data['password']
length = len(password)
if length < 8:
raise forms.ValidationError("Password has to be at least 8 characters long.")
return password
def account(request):
if request.method == 'POST': # If the form has been submitted...
form = ContactForm(request.POST) # A form bound to the POST data
if form.is_valid(): # All validation rules pass
name = form.cleaned_data['name']
firstname = form.cleaned_data['firstname']
email = form.cleaned_data['email']
message = form.cleaned_data['message']
password = form.cleaned_data['password']
# do_something
# then return
return redirect('success') # Redirect after POST
else:
form = ContactForm() # An unbound form
return render_to_response('account.html', {'form' : form}, context_instance=RequestContext(request))
def success(request):
return HttpResponse('success')
def index(request):
return render_to_response('index.html')
le formulaire de la page account s'affiche correctement par contre celui de la page login ne s'affiche même pas
voici le code du formulaire login
<form id="contact" action="{% url login %}" method="post" class="niceform" novalidate>{% csrf_token %}
<table border="0" cellspacing="0" cellpadding="0" align="center" width="436" height="91" bgcolor="#ffffff">
<tr valign="top">
<td width="182" height="34">
{{ form.login1.label_tag }} :</td>
<td width="113">{{ form.login1 }}</td>
<td width="141">{{ form.login1.errors }}</td>
</tr>
<tr>
<td height="57">{{ form.password1.label_tag }} :</td>
<td>{{ form.password1 }}</td>
<td>{{ form.password1.errors }}</td>
</tr> </table>
<table border="0" cellspacing="0" cellpadding="0" align="center" width="55" height="24">
<tr>
<td width="55" height="24"> <input type="submit" value="Submit" /></td></tr>
</table>
</form>
ça peut être dû à quoi la non affichage du formulaire de la page login?
merci
Hors ligne
bonjour
c'est résolu c'est une erreur d'inattention.
merci
Hors ligne