when click <a herf ="...">,the corresponding view function was called twice,why?

8 views
Skip to first unread message

hao he

unread,
Oct 17, 2009, 11:59:53 AM10/17/09
to Django users
with the follow code/config,one request lead to view function was
execute twice。


--------------------------------------------------------------------------------------------------
url config:
url(r'^ader/basic/(?P<ad_id>[0-9]+)/
$',ader_basic,name='ad_ader_basic'),
--------------------------------------------------------------------------------------------------
view function:
def ader_basic(request,ad_id=None,template = "advertise/
ad_wizard_basic.html"):
print 'ader_basic'
--------------------------------------------------------------------------------------------------
template:
<a href=" {%url ad_ader_basic ad_id%} "basic info</a>
-----------------------------------------------------------------------------------------------
Validating models...
0 errors found
-------------------------------------------------------------------
submit a request,lead to view_function was called twice!
why?
--------------
Django version 1.1, using settings 'bxdc_project.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
ader_basic #print first time when
[17/Oct/2009 23:48:11] "GET /advertise/ader/basic/2/ HTTP/1.1" 200
121201
[17/Oct/2009 23:48:11] "GET /site_media/blueprint/src/reset.css HTTP/
1.1" 304 0
[17/Oct/2009 23:48:11] "GET /site_media/jquery.js HTTP/1.1" 304 0
ader_basic # print twice
[17/Oct/2009 23:48:11] "GET /advertise/ader/basic/2/ HTTP/1.1" 200
68221
[17/Oct/2009 23:48:11] "GET /site_media/img/logo.png HTTP/1.1" 304 0

hao he

unread,
Oct 17, 2009, 11:59:59 AM10/17/09
to Django users

ringemup

unread,
Oct 17, 2009, 12:04:10 PM10/17/09
to Django users

I've had that problem when a stylesheet import in my document head
used an empty string for the path -- the browser called the same URL
as for the document in an attempt to import the stylesheet.

On Oct 17, 11:59 am, hao he <speed...@gmail.com> wrote:
> with the follow code/config,one request lead to view function was
> execute twice。
>
> --------------------------------------------------------------------------------------------------
> url config:
> url(r'^ader/basic/(?P<ad_id>[0-9]+)/
> $',ader_basic,name='ad_ader_basic'),
> --------------------------------------------------------------------------------------------------
> view function:
> def ader_basic(request,ad_id=None,template = "advertise/
> ad_wizard_basic.html"):
> print 'ader_basic'
> --------------------------------------------------------------------------------------------------
> template:
> <a href=" {%url ad_ader_basic ad_id%} "basic info</a>
> -----------------------------------------------------------------------------------------------
> Validating models...
> 0 errors found
> -------------------------------------------------------------------
> submit a request,lead to view_function was called twice!
> why?
> --------------
> Django version 1.1, using settings 'bxdc_project.settings'
> Development server is running athttp://127.0.0.1:8000/

bruno desthuilliers

unread,
Oct 17, 2009, 12:43:46 PM10/17/09
to Django users
On 17 oct, 17:59, hao he <speed...@gmail.com> wrote:
> with the follow code/config,one request   lead to  view function was
> execute twice。
>
> --------------------------------------------------------------------------------------------------
> template:
> <a href=" {%url ad_ader_basic ad_id%} "basic info</a>

If that's copy-pasted from your code (as it should be) then your <a>
tag is incorrect - it should be:
Reply all
Reply to author
Forward
0 new messages