request.POST is empty in django 1.11 gae app in ajax call
up vote
0
down vote
favorite
I updated my django google app engine application from 1.2 to 1.11 and do "revelant" steps (python 2.7), such as
urlpatterns = patterns('',
url(r'^$','froom.views.index', name='index'),
to
urlpatterns = [
url(r'^$',views.index, name='index'),
and start to use django cripsy forms.
while I run 1.2 version and post form, and get request.POST has dict value with posted form values,
however with 1.11 version, request.POST is empty.
request.POST = <QueryDict: {}>
I double check my ajax calls comes with
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
as noted here
My method stays same:
def edit_tenant(request, tenant_id=None):
if (request.method == 'POST'):
if tenant_id:
tenant_id_int = long(tenant_id)
tenant_org = db.get(db.Key.from_path('Tenant', tenant_id_int))
form = TenantForm(request.POST, instance = tenant_org, prefix = "edittenant")
django settings.py as below:
working version one's:
TEMPLATE_DIRS = (
os.path.join(os.path.dirname(__file__), 'templates'),
)
none working version one's:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(os.path.dirname(__file__), 'templates'),
os.path.join(os.path.dirname(__file__), 'myapplication'),
],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
What could be issue that upgraded versions request.POST is empty?
python django google-app-engine
add a comment |
up vote
0
down vote
favorite
I updated my django google app engine application from 1.2 to 1.11 and do "revelant" steps (python 2.7), such as
urlpatterns = patterns('',
url(r'^$','froom.views.index', name='index'),
to
urlpatterns = [
url(r'^$',views.index, name='index'),
and start to use django cripsy forms.
while I run 1.2 version and post form, and get request.POST has dict value with posted form values,
however with 1.11 version, request.POST is empty.
request.POST = <QueryDict: {}>
I double check my ajax calls comes with
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
as noted here
My method stays same:
def edit_tenant(request, tenant_id=None):
if (request.method == 'POST'):
if tenant_id:
tenant_id_int = long(tenant_id)
tenant_org = db.get(db.Key.from_path('Tenant', tenant_id_int))
form = TenantForm(request.POST, instance = tenant_org, prefix = "edittenant")
django settings.py as below:
working version one's:
TEMPLATE_DIRS = (
os.path.join(os.path.dirname(__file__), 'templates'),
)
none working version one's:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(os.path.dirname(__file__), 'templates'),
os.path.join(os.path.dirname(__file__), 'myapplication'),
],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
What could be issue that upgraded versions request.POST is empty?
python django google-app-engine
Probably to do with CSRF protection, although I'm surprised you don't get a 403 error.
– Daniel Roseman
Nov 9 at 15:18
I tried with CSRF as well, but not success
– asdf_enel_hak
Nov 9 at 15:19
What did you do to try "with CSRF"?
– Daniel Roseman
Nov 9 at 15:21
@DanielRoseman Thanks, I posted how the issue resolved as answer. Thanks again for direction to right point
– asdf_enel_hak
Nov 9 at 16:06
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I updated my django google app engine application from 1.2 to 1.11 and do "revelant" steps (python 2.7), such as
urlpatterns = patterns('',
url(r'^$','froom.views.index', name='index'),
to
urlpatterns = [
url(r'^$',views.index, name='index'),
and start to use django cripsy forms.
while I run 1.2 version and post form, and get request.POST has dict value with posted form values,
however with 1.11 version, request.POST is empty.
request.POST = <QueryDict: {}>
I double check my ajax calls comes with
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
as noted here
My method stays same:
def edit_tenant(request, tenant_id=None):
if (request.method == 'POST'):
if tenant_id:
tenant_id_int = long(tenant_id)
tenant_org = db.get(db.Key.from_path('Tenant', tenant_id_int))
form = TenantForm(request.POST, instance = tenant_org, prefix = "edittenant")
django settings.py as below:
working version one's:
TEMPLATE_DIRS = (
os.path.join(os.path.dirname(__file__), 'templates'),
)
none working version one's:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(os.path.dirname(__file__), 'templates'),
os.path.join(os.path.dirname(__file__), 'myapplication'),
],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
What could be issue that upgraded versions request.POST is empty?
python django google-app-engine
I updated my django google app engine application from 1.2 to 1.11 and do "revelant" steps (python 2.7), such as
urlpatterns = patterns('',
url(r'^$','froom.views.index', name='index'),
to
urlpatterns = [
url(r'^$',views.index, name='index'),
and start to use django cripsy forms.
while I run 1.2 version and post form, and get request.POST has dict value with posted form values,
however with 1.11 version, request.POST is empty.
request.POST = <QueryDict: {}>
I double check my ajax calls comes with
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
as noted here
My method stays same:
def edit_tenant(request, tenant_id=None):
if (request.method == 'POST'):
if tenant_id:
tenant_id_int = long(tenant_id)
tenant_org = db.get(db.Key.from_path('Tenant', tenant_id_int))
form = TenantForm(request.POST, instance = tenant_org, prefix = "edittenant")
django settings.py as below:
working version one's:
TEMPLATE_DIRS = (
os.path.join(os.path.dirname(__file__), 'templates'),
)
none working version one's:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [
os.path.join(os.path.dirname(__file__), 'templates'),
os.path.join(os.path.dirname(__file__), 'myapplication'),
],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
What could be issue that upgraded versions request.POST is empty?
python django google-app-engine
python django google-app-engine
asked Nov 9 at 15:12
asdf_enel_hak
6,02532664
6,02532664
Probably to do with CSRF protection, although I'm surprised you don't get a 403 error.
– Daniel Roseman
Nov 9 at 15:18
I tried with CSRF as well, but not success
– asdf_enel_hak
Nov 9 at 15:19
What did you do to try "with CSRF"?
– Daniel Roseman
Nov 9 at 15:21
@DanielRoseman Thanks, I posted how the issue resolved as answer. Thanks again for direction to right point
– asdf_enel_hak
Nov 9 at 16:06
add a comment |
Probably to do with CSRF protection, although I'm surprised you don't get a 403 error.
– Daniel Roseman
Nov 9 at 15:18
I tried with CSRF as well, but not success
– asdf_enel_hak
Nov 9 at 15:19
What did you do to try "with CSRF"?
– Daniel Roseman
Nov 9 at 15:21
@DanielRoseman Thanks, I posted how the issue resolved as answer. Thanks again for direction to right point
– asdf_enel_hak
Nov 9 at 16:06
Probably to do with CSRF protection, although I'm surprised you don't get a 403 error.
– Daniel Roseman
Nov 9 at 15:18
Probably to do with CSRF protection, although I'm surprised you don't get a 403 error.
– Daniel Roseman
Nov 9 at 15:18
I tried with CSRF as well, but not success
– asdf_enel_hak
Nov 9 at 15:19
I tried with CSRF as well, but not success
– asdf_enel_hak
Nov 9 at 15:19
What did you do to try "with CSRF"?
– Daniel Roseman
Nov 9 at 15:21
What did you do to try "with CSRF"?
– Daniel Roseman
Nov 9 at 15:21
@DanielRoseman Thanks, I posted how the issue resolved as answer. Thanks again for direction to right point
– asdf_enel_hak
Nov 9 at 16:06
@DanielRoseman Thanks, I posted how the issue resolved as answer. Thanks again for direction to right point
– asdf_enel_hak
Nov 9 at 16:06
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
The issue resolved with "@Daniel Roseman" comments which points to csrf token:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.contenttypes',
'django.contrib.auth',
'myapplication',
'django_forms_bootstrap',
'crispy_forms',
)
when I add 'django.contrib.auth',
and update :
return render_to_response('edit_tenant.html')
to
return render(request, 'edit_tenant.html')
It puts
<input type='hidden' name='csrfmiddlewaretoken' value='itg3eY4YnesCy6p5enJS19txbMDI49Gf4UUEPQjOkUtyoEDBBO1L8nyborVD9prW' />
However I should have add 'django.middleware.csrf.CsrfViewMiddleware'
to MIDDLEWARE_CLASSES
as well:
MIDDLEWARE_CLASSES = (
'django.middleware.csrf.CsrfViewMiddleware',
'gaesessions.DjangoSessionMiddleware',
)
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
The issue resolved with "@Daniel Roseman" comments which points to csrf token:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.contenttypes',
'django.contrib.auth',
'myapplication',
'django_forms_bootstrap',
'crispy_forms',
)
when I add 'django.contrib.auth',
and update :
return render_to_response('edit_tenant.html')
to
return render(request, 'edit_tenant.html')
It puts
<input type='hidden' name='csrfmiddlewaretoken' value='itg3eY4YnesCy6p5enJS19txbMDI49Gf4UUEPQjOkUtyoEDBBO1L8nyborVD9prW' />
However I should have add 'django.middleware.csrf.CsrfViewMiddleware'
to MIDDLEWARE_CLASSES
as well:
MIDDLEWARE_CLASSES = (
'django.middleware.csrf.CsrfViewMiddleware',
'gaesessions.DjangoSessionMiddleware',
)
add a comment |
up vote
0
down vote
The issue resolved with "@Daniel Roseman" comments which points to csrf token:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.contenttypes',
'django.contrib.auth',
'myapplication',
'django_forms_bootstrap',
'crispy_forms',
)
when I add 'django.contrib.auth',
and update :
return render_to_response('edit_tenant.html')
to
return render(request, 'edit_tenant.html')
It puts
<input type='hidden' name='csrfmiddlewaretoken' value='itg3eY4YnesCy6p5enJS19txbMDI49Gf4UUEPQjOkUtyoEDBBO1L8nyborVD9prW' />
However I should have add 'django.middleware.csrf.CsrfViewMiddleware'
to MIDDLEWARE_CLASSES
as well:
MIDDLEWARE_CLASSES = (
'django.middleware.csrf.CsrfViewMiddleware',
'gaesessions.DjangoSessionMiddleware',
)
add a comment |
up vote
0
down vote
up vote
0
down vote
The issue resolved with "@Daniel Roseman" comments which points to csrf token:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.contenttypes',
'django.contrib.auth',
'myapplication',
'django_forms_bootstrap',
'crispy_forms',
)
when I add 'django.contrib.auth',
and update :
return render_to_response('edit_tenant.html')
to
return render(request, 'edit_tenant.html')
It puts
<input type='hidden' name='csrfmiddlewaretoken' value='itg3eY4YnesCy6p5enJS19txbMDI49Gf4UUEPQjOkUtyoEDBBO1L8nyborVD9prW' />
However I should have add 'django.middleware.csrf.CsrfViewMiddleware'
to MIDDLEWARE_CLASSES
as well:
MIDDLEWARE_CLASSES = (
'django.middleware.csrf.CsrfViewMiddleware',
'gaesessions.DjangoSessionMiddleware',
)
The issue resolved with "@Daniel Roseman" comments which points to csrf token:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.contenttypes',
'django.contrib.auth',
'myapplication',
'django_forms_bootstrap',
'crispy_forms',
)
when I add 'django.contrib.auth',
and update :
return render_to_response('edit_tenant.html')
to
return render(request, 'edit_tenant.html')
It puts
<input type='hidden' name='csrfmiddlewaretoken' value='itg3eY4YnesCy6p5enJS19txbMDI49Gf4UUEPQjOkUtyoEDBBO1L8nyborVD9prW' />
However I should have add 'django.middleware.csrf.CsrfViewMiddleware'
to MIDDLEWARE_CLASSES
as well:
MIDDLEWARE_CLASSES = (
'django.middleware.csrf.CsrfViewMiddleware',
'gaesessions.DjangoSessionMiddleware',
)
edited Nov 9 at 17:42
answered Nov 9 at 16:05
asdf_enel_hak
6,02532664
6,02532664
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53228371%2frequest-post-is-empty-in-django-1-11-gae-app-in-ajax-call%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Probably to do with CSRF protection, although I'm surprised you don't get a 403 error.
– Daniel Roseman
Nov 9 at 15:18
I tried with CSRF as well, but not success
– asdf_enel_hak
Nov 9 at 15:19
What did you do to try "with CSRF"?
– Daniel Roseman
Nov 9 at 15:21
@DanielRoseman Thanks, I posted how the issue resolved as answer. Thanks again for direction to right point
– asdf_enel_hak
Nov 9 at 16:06