beginner . problem simple form.

74 views
Skip to first unread message

Jordi Fernandez

unread,
Aug 21, 2016, 8:51:01 AM8/21/16
to Django users
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

ludovic coues

unread,
Aug 21, 2016, 9:41:07 AM8/21/16
to django...@googlegroups.com
Do you have any message in the console where you run "python manage.py
runserver" ?
> --
> 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

Vijay Khemlani

unread,
Aug 22, 2016, 8:32:24 AM8/22/16
to django...@googlegroups.com
Also, why do you have two form tags in your html?


> 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...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

ludovic coues

unread,
Aug 22, 2016, 4:38:39 PM8/22/16
to django...@googlegroups.com
The second form tag is in an html comment. Everything inside <!-- -->
won't be rendered.
>> > 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...@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/CAEuG%2BTbsnWXo0iF0%2BaNwY3KV1AZXj74bCh4w3jrt86KL1RCTXQ%40mail.gmail.com.
>> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> 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/CALn3ei3ReDgYhXY4yabQ2v-QMNcLD5tzOadoxC9cxTaBcPP-cQ%40mail.gmail.com.

Andromeda Yelton

unread,
Aug 22, 2016, 10:19:19 PM8/22/16
to django...@googlegroups.com
Is 'dojo.views.reportaralumnos' an appropriate argument for redirect()? See https://docs.djangoproject.com/en/1.10/topics/http/shortcuts/#redirect - it's looking for the name of a URL or the actual callable view object (such as you might feed to reverse() - https://docs.djangoproject.com/en/1.10/ref/urlresolvers/#django.urls.reverse), not the import path of a view.

--
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.



--
Andromeda Yelton
Vice President/President-Elect, Library & Information Technology Association: http://www.lita.org

Jordi Fernandez

unread,
Aug 30, 2016, 12:56:39 PM8/30/16
to Django users

yes  , we are test
El dilluns, 22 agost de 2016 22:38:39 UTC+2, ludovic coues va escriure:

Jordi Fernandez

unread,
Aug 30, 2016, 12:57:31 PM8/30/16
to Django users
the second is a comment

El dimarts, 30 agost de 2016 18:56:39 UTC+2, Jordi Fernandez va escriure:

Jordi Fernandez

unread,
Aug 30, 2016, 1:03:30 PM8/30/16
to Django users
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:
Reply all
Reply to author
Forward
0 new messages