Tuesday, August 30, 2016

Re: beginner . problem simple form.

console no message, I see  in one second what form search in bad url , bad because I want to the same view.(url)  It's search in http://127.0.0.1:8000/crearasistenciaclasse/crearasistenciaclasse
 this  is incorrect the correct is http://127.0.0.1:8000/crearasistenciaclasse



El diumenge, 21 agost de 2016 15:41:07 UTC+2, ludovic coues va escriure:
Do you have any message in the console where you run "python manage.py
runserver" ?

2016-08-21 12:16 GMT+02:00 Jordi Fernandez <fernand...@gmail.com>:
> hi,
>
> I have my firts application django it's fine. . But! I have a problem with a
> simple form. I  think this  is a problem the my experience of all entorn (
> html, form action, ..)
>
> the problem is when a submit my form is a eror -> ERROR LOADING PAGE
>
> if I test my script I not received a method post. why?
>
>
>
> thank you
>
>
> This is my template form
>
> <form action="/crearassistenciaclasse/" method="post" >{% csrf_token %}
> {{ form.name.errors }}
> <!--
> <form action="/login/"   method="POST" >
> {% csrf_token %}
> -->
>
> {{form.as_p}}
>
> <!--
> <button type="submit" class="save btn btn-default">Save</button>
> -->
> <input type="submit" value="Crear Assistencia">
>
> </form>
>
>
> this is my wiew
>
> def crearasistenciaclasse(request):
>     #return HttpResponse('ok')
>
>     if request.method == "POST":
> form = CrearasistenciaclasseForm(request.POST)
> if form.is_valid():
>            Asistencia = form.save()
>            return redirect('dojo.views.reportaralumnos')
>     else:
>         user = 6
>         form = CrearasistenciaclasseForm(my_arg=user)
>
>     return render_to_response('asistencias/crearasistenciaclasse.html',
> {'form': form})
>
>
>
>
>
>
>
>
>
> this is my form
>
> class CrearasistenciaclasseForm(forms.Form):
>     alumnos = forms.ModelChoiceField(queryset=Alumno.objects.all())
>     classesobertes =
> forms.ModelChoiceField(queryset=Classe.objects.filter(estado='A'))
>     def __init__(self, *args, **kwargs):
> my_arg = kwargs.pop('my_arg')
> super(CrearasistenciaclasseForm, self).__init__(*args, **kwargs)
>
> self.fields['classesobertes'].label = "Classe"
>
> self.fields['alumnos'].initial = my_arg
>
> --
> 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...@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/71bb6ab8-e14a-47aa-91ad-57d4ac29e6f0%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--

Cordialement, Coues Ludovic
+336 148 743 42

--
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-users@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/4cbcd76a-1d38-45cd-8680-438cde64ad17%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment