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?










share|improve this question






















  • 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















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?










share|improve this question






















  • 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













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?










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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


















  • 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












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',
)





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    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

























    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',
    )





    share|improve this answer



























      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',
      )





      share|improve this answer

























        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',
        )





        share|improve this answer














        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',
        )






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 9 at 17:42

























        answered Nov 9 at 16:05









        asdf_enel_hak

        6,02532664




        6,02532664






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Schultheiß

            Verwaltungsgliederung Dänemarks

            Liste der Kulturdenkmale in Wilsdruff