Re: Two {% csrf_token %} processed for _accounts/settings. Is this an issue?

2022-01-11 Thread Robbi Nespu



On 10/1/2022 4:56 am, Al Go wrote:
PS: I tried asking on #django, but kept getting the following error with 
the in browser liberia irc client: "Cannot join channel (+r) - you need 
to be logged into your NickServ account"


You need to login on IRC, the channel set that rules (as normally to 
fight bots)


+r means you won’t be able to join it unless you are registered and 
identified to NickServ. You can follow steps on 
https://libera.chat/guides/registration for registration



Inspect element in http://127.0.0.1:8000/_accounts/settings/ (when running the 
testproject) shows two identical hidden input fields with 
name="csrfmiddlewaretoken". They seem to be generated by two occurrences of {% 
csrf_token %}:


CSRF middleware is activated by default


Should/could the first occurrence above be removed? I'm guessing this would NOT 
cause any actual bug either way,


If your form POST target are external website/url , then it should be 
removed because it cause leak of CSRF token which consider as 
vulnerability issue.


If you form target are internal, you can remove it but it better to keep 
it as defense against unsafe CSRF attack


read https://docs.djangoproject.com/en/4.0/ref/csrf/ for more 
information if you might find something


regarding having more than 1 csrf token, it looks wrong. Should only 
have 1 token per form like example 
https://paste.debian.net/plain/1226800 as what I understand we only 
should send a single CSRF token in the HTTP header.


Does you get any exception when submit the form that have 2 csrf token?


--
Regards
Robbi Nespu

PGP: D311 B5FF EEE6 0BE8 9C91 FA9E 0C81 FA30 3B3A 80BA

--
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4adce4df-ddde-bd13-4f10-76fb68eab46c%40gmail.com.


OpenPGP_0x0C81FA303B3A80BA.asc
Description: OpenPGP public key


Two {% csrf_token %} processed for _accounts/settings. Is this an issue?

2022-01-09 Thread Al Go
Hello,

I'm a complete newbie and discovering the codebase. Inspect element in
http://127.0.0.1:8000/_accounts/settings/ (when running the testproject)
shows two identical hidden input fields with name="csrfmiddlewaretoken".
They seem to be generated by two occurrences of {% csrf_token %}:
- The first is in the template
wiki/templates/wiki/accounts/account_settings.html, end of line 8
- The second is in the template wiki/templates/wiki/includes/form.html,
beginning of line 1
The second template is included in the first one ({% csrf_token %} is
immediately followed by {% wiki_form form %} on the next line).

Should/could the first occurrence above be removed? I'm guessing this would
NOT cause any actual bug either way,

Chers,
Algorobot42

PS: I tried asking on #django, but kept getting the following error with
the in browser liberia irc client: "Cannot join channel (+r) - you need to
be logged into your NickServ account"

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMJzALP1_YhMc0530sZ2ZDLC%3DxqA9affFu%3DXLUU6WR6Qk4XtrQ%40mail.gmail.com.


Re: reagrding "{% csrf_token %}"issue on my web site login module

2019-05-30 Thread Abdul Qoyyuum
When you run the application and test the login, what do you see in the 
devtool's Network tab? Did you see if csrf_token is null? How about 
document.cookie? Is that also null? Is the document.cookie being passed to 
csrf_token in other ways?

Lots of ways to complete this in Angular/jQuery/Ajax or otherwise is 
presented in this document: https://docs.djangoproject.com/en/2.2/ref/csrf/

-- 
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+unsubscr...@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/38a443bb-26be-45e2-8707-f0f9bf6522ba%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: reagrding "{% csrf_token %}"issue on my web site login module

2019-05-28 Thread Abdulrasheed Ibrahim
For security reasons, It's not recommended to use csrf_exempt, use it only
where security doesn't matter

On Tue, May 28, 2019, 1:13 PM Jeyakanth T  Hi,
> add one more line in your view.py header
>
> from django.views.decorators.csrf import csrf_exempt
>
>
> then add decorator  before your function
>
> @csrf_exempt
>
> With Regards,
>
> Jeyakanth Thangam,
>
>  +91 89739 - 70708, +91 79046 - 48182
>
> jeyakanth0...@gmail.com 
>
>
> On Tue, May 28, 2019 at 5:26 PM isorae dennis 
> wrote:
>
>> Did you indent accurately
>>
>> On Tue, May 28, 2019, 12:32 The Aryas  wrote:
>>
>>> hello guys, i was working on a clone project and got stuck on a problem.
>>> the {% csrf_token %} that i have applied is not verified ...and the error
>>> login module is following>>
>>>
>>>
>>> 
>>> Forbidden (403)
>>>
>>> CSRF verification failed. Request aborted.
>>> Help
>>>
>>> Reason given for failure:
>>>
>>> CSRF token missing or incorrect.
>>>
>>>
>>> In general, this can occur when there is a genuine Cross Site Request
>>> Forgery, or when Django's CSRF mechanism
>>> <https://docs.djangoproject.com/en/2.2/ref/csrf/> has not been used
>>> correctly. For POST forms, you need to ensure:
>>>
>>>- Your browser is accepting cookies.
>>>- The view function passes a request to the template's render
>>>
>>> <https://docs.djangoproject.com/en/dev/topics/templates/#django.template.backends.base.Template.render>
>>> method.
>>>- In the template, there is a {% csrf_token %} template tag inside
>>>each POST form that targets an internal URL.
>>>- If you are not using CsrfViewMiddleware, then you must use
>>>csrf_protect on any views that use the csrf_token template tag, as
>>>well as those that accept the POST data.
>>>- The form has a valid CSRF token. After logging in in another
>>>browser tab or hitting the back button after a login, you may need to
>>>reload the page with the form, because the token is rotated after a 
>>> login.
>>>
>>> You're seeing the help section of this page because you have DEBUG =
>>> True in your Django settings file. Change that to False, and only the
>>> initial error message will be displayed.
>>> You can customize this page using the CSRF_FAILURE_VIEW setting.
>>>
>>>
>>> 
>>>
>>> I have applied all the requirements but still that occurs. here is my
>>> code>>
>>>
>>> 
>>>
>>> {% extends 'blog/base.html' %}
>>> {% block content %}
>>> 
>>>   Please login!
>>>   (must be suoer user , please check with site admin)
>>> 
>>> {% if forms.errors %}
>>>   Your user name and password did not match please try again!
>>> {% endif %}
>>>
>>> 
>>> {% csrf_token %}
>>> {{ form.as_p }}
>>>   
>>>   
>>> 
>>> {% endblock %}
>>>
>>>
>>> ===
>>> 
>>>
>>>
>>> from django.contrib import admin
>>> from django.http import HttpResponse
>>> from django.shortcuts import get_object_or_404, render
>>> from django.urls import path
>>> from django.conf.urls import include
>>> from django.contrib.auth import views
>>> urlpatterns = [
>>> path('admin/', admin.site.urls),
>>> path('',include('blog.urls')),
>>> path('accounts/login/',views.LoginView.as_view(), name='login'),
>>> path('accounts/logout/',views.LogoutView.as_view(),
>>> name='logout',kwargs={'next_page':'/'})
>>> ]
>>>
>>>
>>> ===
>>> 
>>> *from django.shortcuts import render,get_object_or_404,redirect*
>>> *from django.utils import timezone*
>>> *from blog.models import Post,Comment*
>>> *from blog.forms import PostForm,CommentForm*
>>

Re: reagrding "{% csrf_token %}"issue on my web site login module

2019-05-28 Thread Jeyakanth T
Hi,
add one more line in your view.py header

from django.views.decorators.csrf import csrf_exempt


then add decorator  before your function

@csrf_exempt

With Regards,

Jeyakanth Thangam,

 +91 89739 - 70708, +91 79046 - 48182

jeyakanth0...@gmail.com 


On Tue, May 28, 2019 at 5:26 PM isorae dennis  wrote:

> Did you indent accurately
>
> On Tue, May 28, 2019, 12:32 The Aryas  wrote:
>
>> hello guys, i was working on a clone project and got stuck on a problem.
>> the {% csrf_token %} that i have applied is not verified ...and the error
>> login module is following>>
>>
>>
>> 
>> Forbidden (403)
>>
>> CSRF verification failed. Request aborted.
>> Help
>>
>> Reason given for failure:
>>
>> CSRF token missing or incorrect.
>>
>>
>> In general, this can occur when there is a genuine Cross Site Request
>> Forgery, or when Django's CSRF mechanism
>> <https://docs.djangoproject.com/en/2.2/ref/csrf/> has not been used
>> correctly. For POST forms, you need to ensure:
>>
>>- Your browser is accepting cookies.
>>- The view function passes a request to the template's render
>>
>> <https://docs.djangoproject.com/en/dev/topics/templates/#django.template.backends.base.Template.render>
>> method.
>>- In the template, there is a {% csrf_token %} template tag inside
>>each POST form that targets an internal URL.
>>- If you are not using CsrfViewMiddleware, then you must use
>>csrf_protect on any views that use the csrf_token template tag, as
>>well as those that accept the POST data.
>>- The form has a valid CSRF token. After logging in in another
>>browser tab or hitting the back button after a login, you may need to
>>reload the page with the form, because the token is rotated after a login.
>>
>> You're seeing the help section of this page because you have DEBUG = True in
>> your Django settings file. Change that to False, and only the initial
>> error message will be displayed.
>> You can customize this page using the CSRF_FAILURE_VIEW setting.
>>
>>
>> 
>>
>> I have applied all the requirements but still that occurs. here is my
>> code>>
>>
>> 
>>
>> {% extends 'blog/base.html' %}
>> {% block content %}
>> 
>>   Please login!
>>   (must be suoer user , please check with site admin)
>> 
>> {% if forms.errors %}
>>   Your user name and password did not match please try again!
>> {% endif %}
>>
>> 
>> {% csrf_token %}
>> {{ form.as_p }}
>>   
>>   
>> 
>> {% endblock %}
>>
>>
>> ===
>> 
>>
>>
>> from django.contrib import admin
>> from django.http import HttpResponse
>> from django.shortcuts import get_object_or_404, render
>> from django.urls import path
>> from django.conf.urls import include
>> from django.contrib.auth import views
>> urlpatterns = [
>> path('admin/', admin.site.urls),
>> path('',include('blog.urls')),
>> path('accounts/login/',views.LoginView.as_view(), name='login'),
>> path('accounts/logout/',views.LogoutView.as_view(),
>> name='logout',kwargs={'next_page':'/'})
>> ]
>>
>>
>> ===
>> 
>> *from django.shortcuts import render,get_object_or_404,redirect*
>> *from django.utils import timezone*
>> *from blog.models import Post,Comment*
>> *from blog.forms import PostForm,CommentForm*
>> *from django.urls import reverse_lazy*
>> *from django.contrib.auth.decorators import login_required*
>> *from django.contrib.auth.mixins import LoginRequiredMixin*
>> *from django.views.generic import (TemplateView,ListView,*
>> *DetailView,CreateView,*
>> *UpdateView,DeleteView)*
>> *# Create your views here.*
>>
>> *class AboutView(TemplateView):*
>> *template_name='about.html'*
>>
>> *class PostListView(ListView):*
>> *model=Post*
>>
>> *def get_

Re: reagrding "{% csrf_token %}"issue on my web site login module

2019-05-28 Thread isorae dennis
Did you indent accurately

On Tue, May 28, 2019, 12:32 The Aryas  wrote:

> hello guys, i was working on a clone project and got stuck on a problem.
> the {% csrf_token %} that i have applied is not verified ...and the error
> login module is following>>
>
>
> 
> Forbidden (403)
>
> CSRF verification failed. Request aborted.
> Help
>
> Reason given for failure:
>
> CSRF token missing or incorrect.
>
>
> In general, this can occur when there is a genuine Cross Site Request
> Forgery, or when Django's CSRF mechanism
> <https://docs.djangoproject.com/en/2.2/ref/csrf/> has not been used
> correctly. For POST forms, you need to ensure:
>
>- Your browser is accepting cookies.
>- The view function passes a request to the template's render
>
> <https://docs.djangoproject.com/en/dev/topics/templates/#django.template.backends.base.Template.render>
> method.
>- In the template, there is a {% csrf_token %} template tag inside
>each POST form that targets an internal URL.
>- If you are not using CsrfViewMiddleware, then you must use
>csrf_protect on any views that use the csrf_token template tag, as
>well as those that accept the POST data.
>- The form has a valid CSRF token. After logging in in another browser
>tab or hitting the back button after a login, you may need to reload the
>page with the form, because the token is rotated after a login.
>
> You're seeing the help section of this page because you have DEBUG = True in
> your Django settings file. Change that to False, and only the initial
> error message will be displayed.
> You can customize this page using the CSRF_FAILURE_VIEW setting.
>
>
> 
>
> I have applied all the requirements but still that occurs. here is my
> code>>
>
> 
>
> {% extends 'blog/base.html' %}
> {% block content %}
> 
>   Please login!
>   (must be suoer user , please check with site admin)
> 
> {% if forms.errors %}
>   Your user name and password did not match please try again!
> {% endif %}
>
> 
> {% csrf_token %}
> {{ form.as_p }}
>   
>   
> 
> {% endblock %}
>
>
> ===
> 
>
>
> from django.contrib import admin
> from django.http import HttpResponse
> from django.shortcuts import get_object_or_404, render
> from django.urls import path
> from django.conf.urls import include
> from django.contrib.auth import views
> urlpatterns = [
> path('admin/', admin.site.urls),
> path('',include('blog.urls')),
> path('accounts/login/',views.LoginView.as_view(), name='login'),
> path('accounts/logout/',views.LogoutView.as_view(),
> name='logout',kwargs={'next_page':'/'})
> ]
>
>
> ===
> 
> *from django.shortcuts import render,get_object_or_404,redirect*
> *from django.utils import timezone*
> *from blog.models import Post,Comment*
> *from blog.forms import PostForm,CommentForm*
> *from django.urls import reverse_lazy*
> *from django.contrib.auth.decorators import login_required*
> *from django.contrib.auth.mixins import LoginRequiredMixin*
> *from django.views.generic import (TemplateView,ListView,*
> *DetailView,CreateView,*
> *UpdateView,DeleteView)*
> *# Create your views here.*
>
> *class AboutView(TemplateView):*
> *template_name='about.html'*
>
> *class PostListView(ListView):*
> *model=Post*
>
> *def get_queryset(self):*
> *return
> Post.objects.filter(published_date__lte=timezone.now()).order_by('-published_date')*
>
>
> *class PostDetailView(DetailView):*
> *model=Post*
>
> *class CreatePostView(LoginRequiredMixin,CreateView):*
> *login_url='/login'*
> *redirect_field_name='blog/post_detail.html'*
>
> *form_class=PostForm*
>
> *model=Post*
>
>
> *class PostUpdateView(LoginRequiredMixin,UpdateView):*
> *login_url='/login'*
> *redirect_field_name='blog/post_detail.html'*
>
> *form_class=PostForm*
>
> *model=Post*
>
>
> *class PostDeleteView(LoginRequiredMixin,DeleteView):*
> *mod

reagrding "{% csrf_token %}"issue on my web site login module

2019-05-28 Thread The Aryas
hello guys, i was working on a clone project and got stuck on a problem. 
the {% csrf_token %} that i have applied is not verified ...and the error 
login module is following>>


Forbidden (403)

CSRF verification failed. Request aborted.
Help

Reason given for failure:

CSRF token missing or incorrect.


In general, this can occur when there is a genuine Cross Site Request 
Forgery, or when Django's CSRF mechanism 
<https://docs.djangoproject.com/en/2.2/ref/csrf/> has not been used 
correctly. For POST forms, you need to ensure:

   - Your browser is accepting cookies.
   - The view function passes a request to the template's render 
   
<https://docs.djangoproject.com/en/dev/topics/templates/#django.template.backends.base.Template.render>
method.
   - In the template, there is a {% csrf_token %} template tag inside each 
   POST form that targets an internal URL.
   - If you are not using CsrfViewMiddleware, then you must use csrf_protect on 
   any views that use the csrf_token template tag, as well as those that 
   accept the POST data.
   - The form has a valid CSRF token. After logging in in another browser 
   tab or hitting the back button after a login, you may need to reload the 
   page with the form, because the token is rotated after a login.

You're seeing the help section of this page because you have DEBUG = True in 
your Django settings file. Change that to False, and only the initial error 
message will be displayed.
You can customize this page using the CSRF_FAILURE_VIEW setting. 



I have applied all the requirements but still that occurs. here is my code>>



{% extends 'blog/base.html' %}
{% block content %}

  Please login!
  (must be suoer user , please check with site admin)

{% if forms.errors %}
  Your user name and password did not match please try again!
{% endif %}


{% csrf_token %}
{{ form.as_p }}
  
  

{% endblock %}

===



from django.contrib import admin
from django.http import HttpResponse
from django.shortcuts import get_object_or_404, render
from django.urls import path
from django.conf.urls import include
from django.contrib.auth import views
urlpatterns = [
path('admin/', admin.site.urls),
path('',include('blog.urls')),
path('accounts/login/',views.LoginView.as_view(), name='login'),
path('accounts/logout/',views.LogoutView.as_view(), 
name='logout',kwargs={'next_page':'/'})
]

===

*from django.shortcuts import render,get_object_or_404,redirect*
*from django.utils import timezone*
*from blog.models import Post,Comment*
*from blog.forms import PostForm,CommentForm*
*from django.urls import reverse_lazy*
*from django.contrib.auth.decorators import login_required*
*from django.contrib.auth.mixins import LoginRequiredMixin*
*from django.views.generic import (TemplateView,ListView,*
*DetailView,CreateView,*
*UpdateView,DeleteView)*
*# Create your views here.*

*class AboutView(TemplateView):*
*template_name='about.html'*

*class PostListView(ListView):*
*model=Post*

*def get_queryset(self):*
*return 
Post.objects.filter(published_date__lte=timezone.now()).order_by('-published_date')*


*class PostDetailView(DetailView):*
*model=Post*

*class CreatePostView(LoginRequiredMixin,CreateView):*
*login_url='/login'*
*redirect_field_name='blog/post_detail.html'*

*form_class=PostForm*

*model=Post*


*class PostUpdateView(LoginRequiredMixin,UpdateView):*
*login_url='/login'*
*redirect_field_name='blog/post_detail.html'*

*form_class=PostForm*

*model=Post*


*class PostDeleteView(LoginRequiredMixin,DeleteView):*
*model=Post*
*success_url=reverse_lazy('post_list')*


*class DraftListView(LoginRequiredMixin,ListView):*
*login_url='/login/'*
*redirect_field_name='blog/post_list.html'*
*model=Post*

*def get_queryset(self):*
*return 
Post.objects.filter(published_date_isnull=True).order_by('created_date')*

*@login_required*
*def add_comment_to_post(request,pk):*
*post=get_object_or_404(post,pk=pk)*
*if request.method == 'POST':*
*form=CommentForm(request.POST)*
*if form.is_valid():*
*Comment=form.save(commit=False)*
*comment.post=post*
*comment.save()*
*

Re: Generic CBV DeleteView GET csrf_token

2019-03-14 Thread Chetan Ganji
Frameworks dont work as we want them too :P
We have to understand how the defaults are implemented then make the
changes as necessary ;-)
If it can be customized, great! otherwise learn and use a different
framework, LOLZ ;-)


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
I’m
protected online with Avast Free Antivirus. Get it here — it’s free forever.
<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Fri, Mar 15, 2019 at 1:02 AM B  wrote:

> Thanks. I have things working fine under Ajax. This particular scenario is
> an "odd one" since performing a GET on a delete view isn't common, but it
> is implemented by Django. It is helpful for testing, but perhaps the right
> approach is to "disable" get for the DeleteView and be done with it. My
> main concern was for Django to behave "out of box" as intended without
> overrides.
>
> On Thursday, March 14, 2019 at 3:24:46 PM UTC-4, Chetan Ganji wrote:
>>
>> https://www.django-rest-framework.org/topics/ajax-csrf-cors/
>> https://docs.djangoproject.com/en/2.1/ref/csrf/#ajax
>>
>> Regards,
>> Chetan Ganji
>> +91-900-483-4183
>> ganji@gmail.com
>> http://ryucoder.in
>>
>>
>>
>> <https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
>>  I’m
>> protected online with Avast Free Antivirus. Get it here — it’s free
>> forever.
>> <https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
>> <#m_8157490019364007879_CAMKMUjuRMSAqgVxdtNPHEt+RpSzM-VAx9rTgJf7CBqZ91UFtrg@mail.gmail.com_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>
>> On Fri, Mar 15, 2019 at 12:34 AM B  wrote:
>>
>>> I'm implementing a DeleteView, and for completion I would like to
>>> provide the functionality indicated here:
>>>
>>>
>>> https://docs.djangoproject.com/en/2.1/ref/class-based-views/generic-editing/#deleteview
>>>
>>> *If this view is fetched via GET, it will display a confirmation page
>>> that should contain a form that POSTs to the same URL.*
>>>
>>> However, by default a GET will not include the required context to the
>>> template for {% csrf_token %}. How do I include the appropriate context
>>> information for a plain DeleteView CBV?
>>>
>>> --
>>> 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/213ca896-0973-4b64-9345-50de5cd9e5d7%40googlegroups.com
>>> <https://groups.google.com/d/msgid/django-users/213ca896-0973-4b64-9345-50de5cd9e5d7%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> 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+unsubscr...@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/98106b93-47ac-4cbb-8c89-d3291d52b2a5%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/98106b93-47ac-4cbb-8c89-d3291d52b2a5%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> 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+unsubscr...@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/CAMKMUjvEymdFUtQ0qeaPHsie0PsjeuvwkdQC_kkHuHdoeMi8zw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Generic CBV DeleteView GET csrf_token

2019-03-14 Thread B
Thanks. I have things working fine under Ajax. This particular scenario is 
an "odd one" since performing a GET on a delete view isn't common, but it 
is implemented by Django. It is helpful for testing, but perhaps the right 
approach is to "disable" get for the DeleteView and be done with it. My 
main concern was for Django to behave "out of box" as intended without 
overrides.

On Thursday, March 14, 2019 at 3:24:46 PM UTC-4, Chetan Ganji wrote:
>
> https://www.django-rest-framework.org/topics/ajax-csrf-cors/
> https://docs.djangoproject.com/en/2.1/ref/csrf/#ajax
>
> Regards,
> Chetan Ganji
> +91-900-483-4183
> ganji@gmail.com 
> http://ryucoder.in
>
>
>
> <https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
>  I’m 
> protected online with Avast Free Antivirus. Get it here — it’s free 
> forever. 
> <https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
>  
> <#CAMKMUjuRMSAqgVxdtNPHEt+RpSzM-VAx9rTgJf7CBqZ91UFtrg@mail.gmail.com_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> On Fri, Mar 15, 2019 at 12:34 AM B > wrote:
>
>> I'm implementing a DeleteView, and for completion I would like to provide 
>> the functionality indicated here:
>>
>>
>> https://docs.djangoproject.com/en/2.1/ref/class-based-views/generic-editing/#deleteview
>>
>> *If this view is fetched via GET, it will display a confirmation page 
>> that should contain a form that POSTs to the same URL.*
>>
>> However, by default a GET will not include the required context to the 
>> template for {% csrf_token %}. How do I include the appropriate context 
>> information for a plain DeleteView CBV?
>>
>> -- 
>> 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/213ca896-0973-4b64-9345-50de5cd9e5d7%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/213ca896-0973-4b64-9345-50de5cd9e5d7%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> 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+unsubscr...@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/98106b93-47ac-4cbb-8c89-d3291d52b2a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Generic CBV DeleteView GET csrf_token

2019-03-14 Thread Chetan Ganji
https://www.django-rest-framework.org/topics/ajax-csrf-cors/
https://docs.djangoproject.com/en/2.1/ref/csrf/#ajax

Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
I’m
protected online with Avast Free Antivirus. Get it here — it’s free forever.
<https://www.avast.com/en-in/recommend?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=default3&tag=7ce9710f-d0c2-48a2-a0ba-76107578348e>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Fri, Mar 15, 2019 at 12:34 AM B  wrote:

> I'm implementing a DeleteView, and for completion I would like to provide
> the functionality indicated here:
>
>
> https://docs.djangoproject.com/en/2.1/ref/class-based-views/generic-editing/#deleteview
>
> *If this view is fetched via GET, it will display a confirmation page that
> should contain a form that POSTs to the same URL.*
>
> However, by default a GET will not include the required context to the
> template for {% csrf_token %}. How do I include the appropriate context
> information for a plain DeleteView CBV?
>
> --
> 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+unsubscr...@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/213ca896-0973-4b64-9345-50de5cd9e5d7%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/213ca896-0973-4b64-9345-50de5cd9e5d7%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> 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+unsubscr...@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/CAMKMUjuRMSAqgVxdtNPHEt%2BRpSzM-VAx9rTgJf7CBqZ91UFtrg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Generic CBV DeleteView GET csrf_token

2019-03-14 Thread B
I'm implementing a DeleteView, and for completion I would like to provide 
the functionality indicated here:

https://docs.djangoproject.com/en/2.1/ref/class-based-views/generic-editing/#deleteview

*If this view is fetched via GET, it will display a confirmation page that 
should contain a form that POSTs to the same URL.*

However, by default a GET will not include the required context to the 
template for {% csrf_token %}. How do I include the appropriate context 
information for a plain DeleteView CBV?

-- 
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+unsubscr...@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/213ca896-0973-4b64-9345-50de5cd9e5d7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: {% csrf_token %}

2017-09-27 Thread Chris Wedgwood
Hi Alex

Try this:

return render_to_string('home.html', request=request)

cheers
Chris



On Tuesday, 26 September 2017 18:29:15 UTC+1, Alex Kleider wrote:
>
> I'm using test driven development (going through Harry J.W. Percival's 
> book) and have found that the following code fails because the template tag 
> ( {% csrf_token %} ) is rendered by the home_page view function but not by 
> the django.template.loader.render_to_string function (and so the 
> assertEqual test fails.)
>
> ...templates/home.html:
> ...
> 
>  id="id_new_entity" 
> place_holder="Pick a name for your new entity." /> 
> {% csrf_token %}
>  
> ...
>
> Testing code:
>
> def test_home_page_returns_correct_html(self):
> request = HttpRequest()
> response = home_page(request)
> returned_html = response.content.decode()
> expected_html = render_to_string('home.html')
> self.assertEqual(returned_html , expected_html)
>
> returned_html and expected_html are the same except that returned_html 
> contains the following line (and the other doesn't:)
>  value='Ev0j62rUtwdpOwjS5FN7B1VT38hE75W0JVZUJQy8IpcvzTH0MCexoRSpQvofoDoW' />
> Infact, expected_html doesn't even contain the
> {% csrf_token %}
> line.
>
> Can anyone suggest a work around?
> Thanks in advance.
>
>

-- 
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+unsubscr...@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/4ff3ff89-f6ac-4e82-8d54-964be94e383c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


{% csrf_token %}

2017-09-26 Thread Alex Kleider
I'm using test driven development (going through Harry J.W. Percival's 
book) and have found that the following code fails because the template tag 
( {% csrf_token %} ) is rendered by the home_page view function but not by 
the django.template.loader.render_to_string function (and so the 
assertEqual test fails.)

...templates/home.html:
...

 
    {% csrf_token %}
 
...

Testing code:

def test_home_page_returns_correct_html(self):
request = HttpRequest()
response = home_page(request)
returned_html = response.content.decode()
expected_html = render_to_string('home.html')
self.assertEqual(returned_html , expected_html)

returned_html and expected_html are the same except that returned_html 
contains the following line (and the other doesn't:)

Infact, expected_html doesn't even contain the
{% csrf_token %}
line.

Can anyone suggest a work around?
Thanks in advance.

-- 
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+unsubscr...@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/c424de1a-4866-4f29-b93f-c06f46651ea2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: csrf_token during registration is giving me problems

2017-08-01 Thread pieceofkayk2718
fml.  Thank you.

-- 
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+unsubscr...@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/a7c3f5df-ff30-4d5a-a876-f4614ded0feb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: csrf_token during registration is giving me problems

2017-08-01 Thread pieceofkayk2718
fml.  Thank you.

On Tuesday, August 1, 2017 at 12:55:10 PM UTC-6, Dylan Reinhold wrote:
>
> You have a quoting miss-match in your enctype, that might be messing with 
> the csrf_token
>
>enctype='multipart/form-data">
>
> On Tue, Aug 1, 2017 at 9:57 AM, > 
> wrote:
>
>> Hey,
>>
>> I recently started playing with my user registration and login and logout 
>> stuff for an app.  It worked fine before I moved it but now that it's moved 
>> I keep getting the following error:
>>
>>
>> Forbidden (403) 
>>>
>>> CSRF verification failed. Request aborted.
>>> Help 
>>>
>>> Reason given for failure:
>>>
>>> CSRF token missing or incorrect.
>>> 
>>>
>>> In general, this can occur when there is a genuine Cross Site Request 
>>> Forgery, or when Django's CSRF mechanism 
>>> <https://docs.djangoproject.com/en/1.11/ref/csrf/> has not been used 
>>> correctly. For POST forms, you need to ensure:
>>>
>>>- Your browser is accepting cookies.
>>>    - The view function passes a request to the template's render 
>>>
>>> <https://docs.djangoproject.com/en/dev/topics/templates/#django.template.backends.base.Template.render>
>>>  
>>>method.
>>>- In the template, there is a {% csrf_token %} template tag inside 
>>>each POST form that targets an internal URL.
>>>- If you are not using CsrfViewMiddleware, then you must use 
>>>csrf_protect on any views that use the csrf_token template tag, as 
>>>well as those that accept the POST data.
>>>- The form has a valid CSRF token. After logging in in another 
>>>browser tab or hitting the back button after a login, you may need to 
>>>reload the page with the form, because the token is rotated after a 
>>> login.
>>>
>>> You're seeing the help section of this page because you have DEBUG = 
>>> True in your Django settings file. Change that to False, and only the 
>>> initial error message will be displayed. 
>>>
>>> You can customize this page using the CSRF_FAILURE_VIEW setting.
>>>
>>
>>
>> The following are my codes.  If I'm missing any useful info just let me 
>> know and I'll add it in.
>>
>> views.py 
>> def register(request):
>> # Boolean value.  Upon successful registration, registered will be 
>> changed to True
>> registered = False
>>
>> user_form = UserForm(data=request.POST or None)
>> profile_form = UserProfileForm(data=request.POST or None)
>>
>> if user_form.is_valid() and profile_form.is_valid():
>> user = user_form.save()
>> user.set_password(user.password)
>> user.save()
>> profile = profile_form.save(commit=False)
>> profile.user = user
>> profile.save()
>> registered = True
>>
>> return render(request, 'friends/register.html', {'user_form':
>> user_form, 'profile_form':profile_form, 'registered':registered})
>>
>>
>> register.html
>> {% extends 'hallo/base-k.html' %}
>> {% load staticfiles %}
>>
>> {% block title_block %}
>> Register
>> {% endblock %}
>>
>> {% block body_block %}
>> 
>> 
>>
>> {% if registered %}
>> 
>> 
>> Thank you for registering!
>> 
>> 
>> 
>> 
>> Return to the homepage.
>> 
>> 
>>
>> {% else %}
>> 
>> 
>> Register here!
>> 
>> 
>> 
>> 
>> > 'django.contrib.sessions.middleware.SessionMiddleware',
>> 'django.middleware.common.CommonMiddleware',
>> 'django.middleware.csrf.CsrfViewMiddleware',
>> 'django.contrib.auth.middleware.AuthenticationMiddleware',
>> 'django.contrib.messages.middleware.MessageMiddleware',
>> 'django.middleware.clickjacking.XFrameOptionsMiddleware',
>> ]
>>
>>
>>
>> -- 
>> 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/cecf9272-4567-411b-8fce-c25b542e1598%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/cecf9272-4567-411b-8fce-c25b542e1598%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> 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+unsubscr...@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/a324c1bc-4af3-478d-a290-b6cf0c4f5361%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: csrf_token during registration is giving me problems

2017-08-01 Thread Dylan Reinhold
You have a quoting miss-match in your enctype, that might be messing with
the csrf_token

   I keep getting the following error:
>
>
> Forbidden (403)
>>
>> CSRF verification failed. Request aborted.
>> Help
>>
>> Reason given for failure:
>>
>> CSRF token missing or incorrect.
>>
>>
>> In general, this can occur when there is a genuine Cross Site Request
>> Forgery, or when Django's CSRF mechanism
>> <https://docs.djangoproject.com/en/1.11/ref/csrf/> has not been used
>> correctly. For POST forms, you need to ensure:
>>
>>- Your browser is accepting cookies.
>>- The view function passes a request to the template's render
>>
>> <https://docs.djangoproject.com/en/dev/topics/templates/#django.template.backends.base.Template.render>
>>method.
>>- In the template, there is a {% csrf_token %} template tag inside
>>each POST form that targets an internal URL.
>>- If you are not using CsrfViewMiddleware, then you must use
>>csrf_protect on any views that use the csrf_token template tag, as
>>well as those that accept the POST data.
>>- The form has a valid CSRF token. After logging in in another
>>browser tab or hitting the back button after a login, you may need to
>>reload the page with the form, because the token is rotated after a login.
>>
>> You're seeing the help section of this page because you have DEBUG = True
>> in your Django settings file. Change that to False, and only the initial
>> error message will be displayed.
>>
>> You can customize this page using the CSRF_FAILURE_VIEW setting.
>>
>
>
> The following are my codes.  If I'm missing any useful info just let me
> know and I'll add it in.
>
> views.py
> def register(request):
> # Boolean value.  Upon successful registration, registered will be
> changed to True
> registered = False
>
> user_form = UserForm(data=request.POST or None)
> profile_form = UserProfileForm(data=request.POST or None)
>
> if user_form.is_valid() and profile_form.is_valid():
> user = user_form.save()
> user.set_password(user.password)
> user.save()
> profile = profile_form.save(commit=False)
> profile.user = user
> profile.save()
> registered = True
>
> return render(request, 'friends/register.html', {'user_form':user_form
> , 'profile_form':profile_form, 'registered':registered})
>
>
> register.html
> {% extends 'hallo/base-k.html' %}
> {% load staticfiles %}
>
> {% block title_block %}
> Register
> {% endblock %}
>
> {% block body_block %}
> 
> 
>
> {% if registered %}
> 
> 
> Thank you for registering!
> 
> 
> 
> 
> Return to the homepage.
> 
> 
>
> {% else %}
> 
> 
> Register here!
> 
> 
> 
> 
>  'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> 'django.middleware.clickjacking.XFrameOptionsMiddleware',
> ]
>
>
>
> --
> 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+unsubscr...@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/cecf9272-4567-411b-8fce-c25b542e1598%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/cecf9272-4567-411b-8fce-c25b542e1598%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> 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+unsubscr...@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/CAHtg44BZo_rV407Gt7-75f-T101hF8kg2tQyxjPa3hps9isOcg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


csrf_token during registration is giving me problems

2017-08-01 Thread pieceofkayk2718
Hey,

I recently started playing with my user registration and login and logout 
stuff for an app.  It worked fine before I moved it but now that it's moved 
I keep getting the following error:


Forbidden (403) 
>
> CSRF verification failed. Request aborted.
> Help 
>
> Reason given for failure:
>
> CSRF token missing or incorrect.
> 
>
> In general, this can occur when there is a genuine Cross Site Request 
> Forgery, or when Django's CSRF mechanism 
> <https://docs.djangoproject.com/en/1.11/ref/csrf/> has not been used 
> correctly. For POST forms, you need to ensure:
>
>- Your browser is accepting cookies.
>- The view function passes a request to the template's render 
>
> <https://docs.djangoproject.com/en/dev/topics/templates/#django.template.backends.base.Template.render>
>  
>method.
>- In the template, there is a {% csrf_token %} template tag inside 
>each POST form that targets an internal URL.
>- If you are not using CsrfViewMiddleware, then you must use 
>csrf_protect on any views that use the csrf_token template tag, as 
>well as those that accept the POST data.
>- The form has a valid CSRF token. After logging in in another browser 
>tab or hitting the back button after a login, you may need to reload the 
>page with the form, because the token is rotated after a login.
>
> You're seeing the help section of this page because you have DEBUG = True 
> in your Django settings file. Change that to False, and only the initial 
> error message will be displayed. 
>
> You can customize this page using the CSRF_FAILURE_VIEW setting.
>


The following are my codes.  If I'm missing any useful info just let me 
know and I'll add it in.

views.py 
def register(request):
# Boolean value.  Upon successful registration, registered will be 
changed to True
registered = False

user_form = UserForm(data=request.POST or None)
profile_form = UserProfileForm(data=request.POST or None)

if user_form.is_valid() and profile_form.is_valid():
user = user_form.save()
user.set_password(user.password)
user.save()
profile = profile_form.save(commit=False)
profile.user = user
profile.save()
registered = True

return render(request, 'friends/register.html', {'user_form':user_form, 
'profile_form':profile_form, 'registered':registered})


register.html
{% extends 'hallo/base-k.html' %}
{% load staticfiles %}

{% block title_block %}
Register
{% endblock %}

{% block body_block %}



{% if registered %}


Thank you for registering!




Return to the homepage.



{% else %}


Register here!




https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/cecf9272-4567-411b-8fce-c25b542e1598%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: csrf_token is not being set when using Jinja2

2014-01-18 Thread Chen Xu
That gives me :

Encountered unknown tag 'csrf_token'.



Thanks




On Sat, Jan 18, 2014 at 8:57 PM, Mario Gudelj wrote:

> Try {% csrf_token %} by itself
> On 19/01/2014 12:12 pm, "Chen Xu"  wrote:
>
>> Hi everyone,
>> I am using Jinja2 instead of Django's own template engine, however I am
>> having an issue where csrf_token is empty, I included the following line in
>> my form:
>>
>> 
>>
>> But csrf_token has no value.
>>
>> Can someone help?
>>
>>
>> Thanks in advance
>>
>>
>> --
>> ⚡ Chen Xu ⚡
>>
>> --
>> 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+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@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/CACac-qZ%3D6CT6yO48dQKEDX%3DuhCZ%2BXzrHraNa1qru2H%2BbCTP5rA%40mail.gmail.com
>> .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>  --
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@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/CAHqTbjkPA3nBDE0K5-Osdj2f5Wy4v9fFugLa%3DwPst-w5iRucEw%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
⚡ Chen Xu ⚡

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/CACac-qYoS%2BMvE751%2BYyXO7Q50WXoBzosb0v0JjEhEbwnyiZUcA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: csrf_token is not being set when using Jinja2

2014-01-18 Thread Mario Gudelj
Try {% csrf_token %} by itself
On 19/01/2014 12:12 pm, "Chen Xu"  wrote:

> Hi everyone,
> I am using Jinja2 instead of Django's own template engine, however I am
> having an issue where csrf_token is empty, I included the following line in
> my form:
>
> 
>
> But csrf_token has no value.
>
> Can someone help?
>
>
> Thanks in advance
>
>
> --
> ⚡ Chen Xu ⚡
>
> --
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@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/CACac-qZ%3D6CT6yO48dQKEDX%3DuhCZ%2BXzrHraNa1qru2H%2BbCTP5rA%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/CAHqTbjkPA3nBDE0K5-Osdj2f5Wy4v9fFugLa%3DwPst-w5iRucEw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


csrf_token is not being set when using Jinja2

2014-01-18 Thread Chen Xu
Hi everyone,
I am using Jinja2 instead of Django's own template engine, however I am
having an issue where csrf_token is empty, I included the following line in
my form:



But csrf_token has no value.

Can someone help?


Thanks in advance


-- 
⚡ Chen Xu ⚡

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/CACac-qZ%3D6CT6yO48dQKEDX%3DuhCZ%2BXzrHraNa1qru2H%2BbCTP5rA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: UserWarning: A {% csrf_token %} was used in a template, but the context did not provide the value.

2013-11-19 Thread huw_at1
Hi,

Many thanks. There is another form in the page which does contain this {% 
csrf_token %} tag. Removing this does remove the warning so this is indeed 
the issue. I just need to write the other form out of the template.

Thanks for the answer :)

On Tuesday, 19 November 2013 13:51:55 UTC, Giulio Calacoci wrote:
>
>  Il 19/11/2013 13:45, huw_at1 ha scritto: 
>
> {% csrf_token %}
>
> If you are using the ajax metod, you don't need this tag in the form 
> template.
>
> According with the documentation, you set the csrf token using javascript 
> in the beforeSend part of the javascript code.
>
>
> Hope I've correctly understood your problem.
>
> Regards.
>
> Giulio
>
> -- 
>  Giulio Calacoci - 2ndQuadrant Italia
>  PostgreSQL Training, Services and Support
>  giulio@2ndquadrant.it  | www.2ndQuadrant.it 
>
>  

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/e599bf09-6e76-45e5-80eb-814986c0260f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: UserWarning: A {% csrf_token %} was used in a template, but the context did not provide the value.

2013-11-19 Thread huw_at1
Hi,

Many thanks. There is another form in the page which does contain this {% 
csrf token %}. Removing this does remove the warning so this is indeed the 
issue. I just need to write the other form out of the template.

Thanks for the answer :)

On Tuesday, 19 November 2013 13:51:55 UTC, Giulio Calacoci wrote:
>
>  Il 19/11/2013 13:45, huw_at1 ha scritto: 
>
> {% csrf_token %}
>
> If you are using the ajax metod, you don't need this tag in the form 
> template.
>
> According with the documentation, you set the csrf token using javascript 
> in the beforeSend part of the javascript code.
>
>
> Hope I've correctly understood your problem.
>
> Regards.
>
> Giulio
>
> -- 
>  Giulio Calacoci - 2ndQuadrant Italia
>  PostgreSQL Training, Services and Support
>  giulio@2ndquadrant.it  | www.2ndQuadrant.it 
>
>  

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/230f16ed-f1d8-4f41-9de8-5ab8d231d397%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: UserWarning: A {% csrf_token %} was used in a template, but the context did not provide the value.

2013-11-19 Thread Giulio Calacoci

Il 19/11/2013 13:45, huw_at1 ha scritto:

{% csrf_token %}
If you are using the ajax metod, you don't need this tag in the form 
template.


According with the documentation, you set the csrf token using 
javascript in the beforeSend part of the javascript code.



Hope I've correctly understood your problem.

Regards.

Giulio

--
 Giulio Calacoci - 2ndQuadrant Italia
 PostgreSQL Training, Services and Support
 giulio.calac...@2ndquadrant.it | www.2ndQuadrant.it

--
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/528B6CFB.2080004%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


UserWarning: A {% csrf_token %} was used in a template, but the context did not provide the value.

2013-11-19 Thread huw_at1
Hi there,

I'm trying to get to the bottom of this warning that I am getting:

/usr/local/lib/python2.7/site-packages/django/template/defaulttags.py:59: 
UserWarning: A {% csrf_token %} was used in a template, but the context did 
not provide the value.  This is usually caused by not using RequestContext.
  warnings.warn("A {% csrf_token %} was used in a template, but the context 
did not provide the value.  This is usually caused by not using 
RequestContext.")

My setup is that I have a form that I am passing to my views via AJAX. I 
prepare the AJAX POST following the guidelines at:

https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax

I am then returning the response using:

return HttpResponse(json.dumps(data), content_type="application/json")

The data returned in the response is then used to update the template that 
also includes the form.

>From the warning I guess I am not returning the CSRF token in the response? 
Is that the issue? I did try adding the @ensure_csrf_cookie decorator to 
the views function but still got this warning. Should I manually return a 
RequestContext and modify my javascript to handle the token accordingly? 
Apologies - it's the first time I've done anything like this...

Many thanks for any help or light anyone can shed on this.

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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/26e4e778-5dbd-45ed-86ea-353f02dc9016%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How to insert a csrf_token when entering datas through a bot ?

2011-04-13 Thread dave b
On 12 April 2011 22:09, JustinMarsan  wrote:
> Hello,
>
> What would be the best way to allow some bots to POST some content to
> a website. Without crsf_token, the bot will get a 403, and I would
> prefer not to remove this behavior but rather find a way to make the
> bot send a token. How could I do that ?
>
> I was thinking of making sure the bot is authorizied to post with some
> identifiers but I guess there might be a better way to do this using
> the built-in token system.
>
> Any ideas ?
>

Why can't you make your bot csrf token aware ?

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



How to insert a csrf_token when entering datas through a bot ?

2011-04-12 Thread JustinMarsan
Hello,

What would be the best way to allow some bots to POST some content to
a website. Without crsf_token, the bot will get a 403, and I would
prefer not to remove this behavior but rather find a way to make the
bot send a token. How could I do that ?

I was thinking of making sure the bot is authorizied to post with some
identifiers but I guess there might be a better way to do this using
the built-in token system.

Any ideas ?

Thank you.

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



Re: csrf_token not enclosed in hidden element

2010-11-04 Thread Erik Cederstrand
Ah, I see. Thanks!

Erik

Den 04/11/2010 kl. 11.17 skrev Menno Luiten:

> That's because you have to use {% csrf_token %} instead of {{ ... }} in your 
> template code. Confusing, perhaps, but have encountered it several times 
> myself.
> 
> Regards,
> Menno
> 
> On 11/04/2010 11:10 AM, Erik Cederstrand wrote:
>> Hi,
>> 
>> I have a view that creates a login page. I use the @csrf_protect decorator 
>> on my view and {{csrf_token}} tag in the template, and the generated 
>> response contains the csrf token. The problem is that the token is printed 
>> as-is instead of being enclosed i a hidden element, as I understand it's 
>> supposed to. Any ideas why?
>> 
>> 
>> My view:
>> 
>> from django.contrib.auth.forms import AuthenticationForm
>> from django.template import RequestContext, loader
>> [...]
>> @csrf_protect
>> def login(response):
>> t = loader.get_template('base/login.html')
>> form = AuthenticationForm()
>> c = RequestContext(request, {
>> 'errormsg': errormsg,
>> 'form': form,
>> })
>> return HttpResponse(t.render(c))
>> 
>> 
>> My template:
>> 
>> {{ csrf_token }}
>> {{ form.as_table }}
>> 
>> 
>> 
>> 
>> The generated HTML is:
>> 
>> 1a3130639851sd8f768b154ba4142d57c8
>> Brugernavn:> id="id_username" type="text" name="username" maxlength="30" />
>> Adgangskode:> type="password" name="password" id="id_password" />
>> 
>> 
>> 
>> 
>> Thanks,
>> Erik
> 
> -- 
> 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.

Med venlig hilsen,

Erik Cederstrand
Affect IT

Tlf: 22 66 07 67
Mail: e...@affect-it.dk



smime.p7s
Description: S/MIME cryptographic signature


Re: csrf_token not enclosed in hidden element

2010-11-04 Thread Menno Luiten
That's because you have to use {% csrf_token %} instead of {{ ... }} in 
your template code. Confusing, perhaps, but have encountered it several 
times myself.


Regards,
Menno

On 11/04/2010 11:10 AM, Erik Cederstrand wrote:

Hi,

I have a view that creates a login page. I use the @csrf_protect decorator on 
my view and {{csrf_token}} tag in the template, and the generated response 
contains the csrf token. The problem is that the token is printed as-is instead 
of being enclosed i a hidden element, as I understand it's supposed to. Any 
ideas why?


My view:

from django.contrib.auth.forms import AuthenticationForm
from django.template import RequestContext, loader
[...]
@csrf_protect
def login(response):
 t = loader.get_template('base/login.html')
 form = AuthenticationForm()
 c = RequestContext(request, {
 'errormsg': errormsg,
 'form': form,
 })
 return HttpResponse(t.render(c))


My template:

{{ csrf_token }}
{{ form.as_table }}




The generated HTML is:

1a3130639851sd8f768b154ba4142d57c8
Brugernavn:
Adgangskode:




Thanks,
Erik


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



csrf_token not enclosed in hidden element

2010-11-04 Thread Erik Cederstrand
Hi,

I have a view that creates a login page. I use the @csrf_protect decorator on 
my view and {{csrf_token}} tag in the template, and the generated response 
contains the csrf token. The problem is that the token is printed as-is instead 
of being enclosed i a hidden element, as I understand it's supposed to. Any 
ideas why?


My view:

from django.contrib.auth.forms import AuthenticationForm
from django.template import RequestContext, loader
[...]
@csrf_protect
def login(response):
t = loader.get_template('base/login.html')
form = AuthenticationForm()
c = RequestContext(request, {
'errormsg': errormsg,
'form': form,
})  
return HttpResponse(t.render(c))


My template:

{{ csrf_token }}
{{ form.as_table }}




The generated HTML is:

1a3130639851sd8f768b154ba4142d57c8
Brugernavn:
Adgangskode:




Thanks,
Erik

smime.p7s
Description: S/MIME cryptographic signature


Re: {% csrf_token %} template tag not outputting the hidden field

2010-09-01 Thread Jonas Geiregat
I had the same problem some day's ago.
Did you add the context_instance parameter in the render_to_reponse function 
call. It's needed for CSRF to work.

For example: return render_to_response('blog/index.html', {'posts': posts}, 
context_instance=RequestContext(req))

Regards,

Jonas.
Op 30-aug-2010, om 20:46 heeft Erik het volgende geschreven:

> Hi Django Users-
> I'm having trouble with the {% csrf_token %} tag.
> On my site I have a regular login view / page / url, which uses
> the django contrib registration app.  I include the CSRF token in my
> login template and it works fine.
> I'd also like a little login box in the corner of every page,
> which will either show a login form or a "you're logged in!" message
> depending on whether the user is logged in.  So, I wrote a little form
> into my base.html template that other templates inherit from; and I
> stuck the {% csrf_token %} tag in there as well.
> The part I don't understand is, if I load the login url in the
> browser ( mysite.com/login/ ) both forms work, I can login with them,
> and when I view the source the CSRF token tag has put a hidden field
> into my form.
> However, when I'm on any other page - for example the front page
> - the token tag just leaves a blank space and doesn't output anything,
> but it doesn't give me an error message on loading the page - as it
> would when I try to use a token tag that doesn't exist - such as {%
> faketokentag  %}.  Of course, because the csrf token tag doesn't
> create any output (in the HTML source generated) when the form is
> submitted the CSRF error occurs.
> I'm rendering all such pages with the generic view
> direct_to_template , which, because it's a generic view, the
> documentation suggests should just work with CSRF.
> Does anyone have any suggestions?
> 
> Thank you,
> Erik
> 
> -- 
> 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.
> 

Met vriendelijke groeten,

Jonas Geiregat
jo...@geiregat.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.



Re: {% csrf_token %} template tag not outputting the hidden field

2010-08-31 Thread Erik
Hi Daniel-
 Thanks for your response.
 No, I wasn't generating the form within django; I had hand coded
a form into the page; because I had intended that this form appear on
every page in the side.
 I'll try it as you suggest and report back.  This may involve
learning how to write template tags.

thanks,
Erik


On Aug 30, 4:16 pm, Daniel Lathrop  wrote:
> I may misunderstand how csrf_token works, but I think it needs to be used in
> conjunction with the forms system, which would require you to pass a form to
> your template. Are you doing that?
>
> Daniel Lathrop
> News Applications Editor
> The Dallas Morning News
> ---
> Daniel Lathrop
> 206.718.0349 (cell)
>
>
>
> On Mon, Aug 30, 2010 at 11:46 AM, Erik  wrote:
> > Hi Django Users-
> >     I'm having trouble with the {% csrf_token %} tag.
> >     On my site I have a regular login view / page / url, which uses
> > the django contrib registration app.  I include the CSRF token in my
> > login template and it works fine.
> >     I'd also like a little login box in the corner of every page,
> > which will either show a login form or a "you're logged in!" message
> > depending on whether the user is logged in.  So, I wrote a little form
> > into my base.html template that other templates inherit from; and I
> > stuck the {% csrf_token %} tag in there as well.
> >     The part I don't understand is, if I load the login url in the
> > browser ( mysite.com/login/ ) both forms work, I can login with them,
> > and when I view the source the CSRF token tag has put a hidden field
> > into my form.
> >     However, when I'm on any other page - for example the front page
> > - the token tag just leaves a blank space and doesn't output anything,
> > but it doesn't give me an error message on loading the page - as it
> > would when I try to use a token tag that doesn't exist - such as {%
> > faketokentag  %}.  Of course, because the csrf token tag doesn't
> > create any output (in the HTML source generated) when the form is
> > submitted the CSRF error occurs.
> >     I'm rendering all such pages with the generic view
> > direct_to_template , which, because it's a generic view, the
> > documentation suggests should just work with CSRF.
> >     Does anyone have any suggestions?
>
> > Thank you,
> > Erik
>
> > --
> > 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 > groups.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 at 
http://groups.google.com/group/django-users?hl=en.



Re: {% csrf_token %} template tag not outputting the hidden field

2010-08-30 Thread Daniel Lathrop
I may misunderstand how csrf_token works, but I think it needs to be used in
conjunction with the forms system, which would require you to pass a form to
your template. Are you doing that?

Daniel Lathrop
News Applications Editor
The Dallas Morning News
---
Daniel Lathrop
206.718.0349 (cell)


On Mon, Aug 30, 2010 at 11:46 AM, Erik  wrote:

> Hi Django Users-
> I'm having trouble with the {% csrf_token %} tag.
> On my site I have a regular login view / page / url, which uses
> the django contrib registration app.  I include the CSRF token in my
> login template and it works fine.
> I'd also like a little login box in the corner of every page,
> which will either show a login form or a "you're logged in!" message
> depending on whether the user is logged in.  So, I wrote a little form
> into my base.html template that other templates inherit from; and I
> stuck the {% csrf_token %} tag in there as well.
> The part I don't understand is, if I load the login url in the
> browser ( mysite.com/login/ ) both forms work, I can login with them,
> and when I view the source the CSRF token tag has put a hidden field
> into my form.
> However, when I'm on any other page - for example the front page
> - the token tag just leaves a blank space and doesn't output anything,
> but it doesn't give me an error message on loading the page - as it
> would when I try to use a token tag that doesn't exist - such as {%
> faketokentag  %}.  Of course, because the csrf token tag doesn't
> create any output (in the HTML source generated) when the form is
> submitted the CSRF error occurs.
> I'm rendering all such pages with the generic view
> direct_to_template , which, because it's a generic view, the
> documentation suggests should just work with CSRF.
> Does anyone have any suggestions?
>
> Thank you,
> Erik
>
> --
> 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 at 
http://groups.google.com/group/django-users?hl=en.



{% csrf_token %} template tag not outputting the hidden field

2010-08-30 Thread Erik
Hi Django Users-
 I'm having trouble with the {% csrf_token %} tag.
 On my site I have a regular login view / page / url, which uses
the django contrib registration app.  I include the CSRF token in my
login template and it works fine.
 I'd also like a little login box in the corner of every page,
which will either show a login form or a "you're logged in!" message
depending on whether the user is logged in.  So, I wrote a little form
into my base.html template that other templates inherit from; and I
stuck the {% csrf_token %} tag in there as well.
 The part I don't understand is, if I load the login url in the
browser ( mysite.com/login/ ) both forms work, I can login with them,
and when I view the source the CSRF token tag has put a hidden field
into my form.
 However, when I'm on any other page - for example the front page
- the token tag just leaves a blank space and doesn't output anything,
but it doesn't give me an error message on loading the page - as it
would when I try to use a token tag that doesn't exist - such as {%
faketokentag  %}.  Of course, because the csrf token tag doesn't
create any output (in the HTML source generated) when the form is
submitted the CSRF error occurs.
 I'm rendering all such pages with the generic view
direct_to_template , which, because it's a generic view, the
documentation suggests should just work with CSRF.
 Does anyone have any suggestions?

Thank you,
Erik

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



Re: Stuck with csrf_token in the tutorial

2009-12-13 Thread Mookie
I just ran into this issue too... seems kind of crazy that the
tutorial doesn't work for the version presented on the "Downloads"
page!

On Nov 9, 9:40 am, wietse  wrote:
> On Nov 9, 3:38 pm, Karen Tracey  wrote:
>
> > On Mon, Nov 9, 2009 at 9:35 AM, wietse  wrote:
> > > Running django 1.1.1
>
> > > I'm going through the tutorial and have run into trouble implementing
> > > a form, I get:
> > >    TemplateSyntaxError at /polls/1/
> > >    Invalid block tag: 'csrf_token'
>
> > csrf_token didn't exist in 1.1.1 -- it's new in the development version.
> > Please use the 1.1 docs:
>
> >http://docs.djangoproject.com/en/1.1/intro/tutorial01/#intro-tutorial01
>
> > (There is an open ticket to get these properly linked from the documentation
> > page.)
>
> Ok, thanks for the quick response!
> Wietse

--

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.




Re: Stuck with csrf_token in the tutorial

2009-11-09 Thread wietse

On Nov 9, 3:38 pm, Karen Tracey  wrote:
> On Mon, Nov 9, 2009 at 9:35 AM, wietse  wrote:
> > Running django 1.1.1
>
> > I'm going through the tutorial and have run into trouble implementing
> > a form, I get:
> >    TemplateSyntaxError at /polls/1/
> >    Invalid block tag: 'csrf_token'
>
> csrf_token didn't exist in 1.1.1 -- it's new in the development version.
> Please use the 1.1 docs:
>
> http://docs.djangoproject.com/en/1.1/intro/tutorial01/#intro-tutorial01
>
> (There is an open ticket to get these properly linked from the documentation
> page.)

Ok, thanks for the quick response!
Wietse
--~--~-~--~~~---~--~~
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
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
-~--~~~~--~~--~--~---



Re: Stuck with csrf_token in the tutorial

2009-11-09 Thread Karen Tracey
On Mon, Nov 9, 2009 at 9:35 AM, wietse  wrote:

>
> Hello,
>
> Running django 1.1.1
>
> I'm going through the tutorial and have run into trouble implementing
> a form, I get:
>TemplateSyntaxError at /polls/1/
>    Invalid block tag: 'csrf_token'
>
>
csrf_token didn't exist in 1.1.1 -- it's new in the development version.
Please use the 1.1 docs:

http://docs.djangoproject.com/en/1.1/intro/tutorial01/#intro-tutorial01

(There is an open ticket to get these properly linked from the documentation
page.)

Karen

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



Stuck with csrf_token in the tutorial

2009-11-09 Thread wietse

Hello,

Running django 1.1.1

I'm going through the tutorial and have run into trouble implementing
a form, I get:
TemplateSyntaxError at /polls/1/
Invalid block tag: 'csrf_token'

I've searched around but find it hard to grok what I need to do. In
settings.py I have:
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.csrf.middleware.CsrfMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
)

The form has a `{% csrf_token %}`, and the view is as per the
tutorial:
def detail(request, poll_id):
p = get_object_or_404(Poll, pk=poll_id)
return render_to_response('polls/detail.html',
{'poll': p},
context_instance=RequestContext(request))

Somewhere I read that if I get this kind of error it means I "have
failed to use the tag loader", but I don't know what that means.

Can somebody show me the way?

Wietse

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