开发者

Django debug console shows double GET for a single page request

I'm running the developer's Django s开发者_StackOverflow中文版erver while writing a simple view and it seems whenever I request a page, the console shows that there are 2 GETs for the same URL. What would cause this happen? I'm not using any redirects, so I don't see how a 2nd request would be made?

EDIT: It appears to be caused by the template. Changing to a blank html file for a template resolved the issue. The question is why? I have multiple {% if %} {% endif %} sections, with no elses. Could that be an issue?


It also could be Firefox following a WC3 directive under which it's supposed to dual load if certain tags come empty or broken, for example, a without a src="" etc. That being said, I saved off the rendered HTML on receipt and moved it into a static file, where I added the same headers as the real checkout and a small DB log of all accesses.

I just stumble upon this problem and fixed it removing my img wit src=""


Please confirm, if Django is redirecting after appending slash to your url. Its the property APPEND_SLASH in your settings.py controls that.


The second request is probably caused by a mis-configured asset link - a script, style or img tag which is empty or omits the initial / and is therefore re-requesting the page.


It could be your shortcut/favicon

Do you have link rel="shortcut icon" in your page template? Comment it out to see if it removes the second request


In my case : I have the same javascript code in 2 files : one in the base template and the same one in another template. As I use ajax to not reload all the page I got the call 2x, then 4x, and 8x, ... The solution is the use the javascript code only in mybase.html Hereafter my js code :

<script type="text/javascript">
// Code jQuery Ici
$(document).ready(function(){

// GET
$(".ajax_onglet_get").click(function(e){
    var lien = $(this).attr('href');
    $('#zone_travail').fadeOut('fast', function(){
        $('#zone_travail').load(lien, function() {
            $('#zone_travail').fadeIn('fast');
        });
    });
    e.preventDefault()
});

});

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜