httml form to django

43 views
Skip to first unread message

dk

unread,
May 20, 2015, 9:24:18 PM5/20/15
to django...@googlegroups.com
i have a regular form in the template.   the user and the password since the web designer did it like that.
can I still use it in django view?

any particular way that's need to be use?  or we need to change it to use django forms?

=)

술욱

unread,
May 20, 2015, 10:41:17 PM5/20/15
to django...@googlegroups.com
Hi,

just make sure you match your input names with what Django expects. For example:

If the HTML is <input name="username"> your Form will need a "username" field.

HTH,
Norberto
> --
> 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/8070bda1-e549-4a3a-89ee-7c1e1df9ff2c%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Luis Zárate

unread,
May 21, 2015, 2:07:11 AM5/21/15
to django...@googlegroups.com
And you need to put inside the form the csrf token .

<form action="." method="post">{% csrf_token %} ...

See: https://docs.djangoproject.com/en/1.8/ref/csrf/



For more options, visit https://groups.google.com/d/optout.



--
"La utopía sirve para caminar" Fernando Birri


dk

unread,
May 21, 2015, 3:10:24 PM5/21/15
to django...@googlegroups.com
I am not going to update any models for the database or anything I just need some info from the user that will be process by the view.
I could put that info in the url as a variable such /?=variable.
and then get it with
info = request.GET.get("info", "") 
but its little ugly since you display it on the url.

Luis Zárate

unread,
May 22, 2015, 3:29:24 AM5/22/15
to django...@googlegroups.com
You don't need to alter any model, only need to create a form class (better) or using request.POST.get("username").

If you want to do in right way
See
https://docs.djangoproject.com/en/1.8/topics/forms/
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/cbe6f8ba-c31e-4fe7-93b2-309178a038b8%40googlegroups.com.

dk

unread,
May 22, 2015, 6:13:51 PM5/22/15
to django...@googlegroups.com
thanks for the help,
at the end I did it with
putting it on the url as a url variable ?var=my_var
and in the view
request.POST.get("username").

thanks for the tips,  super helpful.
Reply all
Reply to author
Forward
0 new messages