Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 Dec. 9, 2010 00:08:59

m.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

CSRF missing token


Hello,

I've a login form which give me an CSRF error.
In the documentation, I read that I needed to have in my code :

# views.py
...
csrf_token = {}
csrf_token.update(csrf(request))
return render_to_response('index.html', locals())

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

But I've an error that the two tokens are different
I guess the problem is in the generation of the token :

<form action="" method="post">
<div style='display:none'><input type='hidden'
name='csrfmiddlewaretoken' value='{'csrf_token':
<django.utils.functional.__proxy__ object at 0x88b1d0c>}' /></div>


It should use value="{'csrf_.... instead of value='{'csrf._..

Any idea how to fix ?

Thanks

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 Dec. 9, 2010 10:56:30

Ilian I.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

CSRF missing token


Hi,

you have to include the request context to use CSRF token.

from django.template import RequestContext

return render_to_response('index.html', locals(), context_instance =
RequestContext(request))

Greeting,
Ilian Iliev

On Thu, Dec 9, 2010 at 2:08 AM, martvefun <martve...@gmail.com> wrote:

> Hello,
>
> I've a login form which give me an CSRF error.
> In the documentation, I read that I needed to have in my code :
>
> # views.py
> ...
> csrf_token = {}
> csrf_token.update(csrf(request))
> return render_to_response('index.html', locals())
>
> # index.html
> ...
> <form action="" method="post">
> {% csrf_token %}
>
> But I've an error that the two tokens are different
> I guess the problem is in the generation of the token :
>
> <form action="" method="post">
> <div style='display:none'><input type='hidden'
> name='csrfmiddlewaretoken' value='{'csrf_token':
> <django.utils.functional.__proxy__ object at 0x88b1d0c>}' /></div>
>
>
> It should use value="{'csrf_.... instead of value='{'csrf._..
>
> Any idea how to fix ?
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
>http://groups.google.com/group/django-users?hl=en.
>
>


--
eng. Ilian Iliev
Web Software Developer

Mobile: +359 88 66 08 400
Website: ilian.i-n-i.org

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#3 Dec. 9, 2010 17:54:32

m.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

CSRF missing token


Hi

Thank you it works well


On 09-12-10 09:15, Ilian Iliev wrote:
> Hi,
>
> you have to include the request context to use CSRF token.
>
> from django.template import RequestContext
>
> return render_to_response('index.html', locals(), context_instance =
> RequestContext(request))
>
> Greeting,
> Ilian Iliev
>
> On Thu, Dec 9, 2010 at 2:08 AM, martvefun <martve...@gmail.com
> <mailto:martve...@gmail.com>> wrote:
>
> Hello,
>
> I've a login form which give me an CSRF error.
> In the documentation, I read that I needed to have in my code :
>
> # views.py
> ...
> csrf_token = {}
> csrf_token.update(csrf(request))
> return render_to_response('index.html', locals())
>
> # index.html
> ...
> <form action="" method="post">
> {% csrf_token %}
>
> But I've an error that the two tokens are different
> I guess the problem is in the generation of the token :
>
> <form action="" method="post">
> <div style='display:none'><input type='hidden'
> name='csrfmiddlewaretoken' value='{'csrf_token':
> <django.utils.functional.__proxy__ object at 0x88b1d0c>}' /></div>
>
>
> It should use value="{'csrf_.... instead of value='{'csrf._..
>
> Any idea how to fix ?
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com
> <mailto:django-users@googlegroups.com>.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> <mailto:django-users%2bunsubscr...@googlegroups.com>.
> For more options, visit this group at
>http://groups.google.com/group/django-users?hl=en.
>
>
>
>
> --
> eng. Ilian Iliev
> Web Software Developer
>
> Mobile: +359 88 66 08 400
> Website: ilian.i-n-i.org <http://ilian.i-n-i.org>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
>http://groups.google.com/group/django-users?hl=en.

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

Board footer

Moderator control

Enjoy the 21st of August
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support