On May 19, 7:32 pm, "free won" <[EMAIL PROTECTED]> wrote:
> i found this Problem  when i decide to use Paginator.
>
> the str    *(?P<query>\w+/)$*     can express    * ?query=xxx*
>
> so if i wanna express *?query=xxx&page=1*,  how can I write the str for
> urls.py?

The part of the url following (and including) the question mark is not
actually part of the url, if you see what I mean, but is actually the
data passed as GET data. And Django provides an easy way to get at
this. Example,

The address required is : "http://www.mysite.com/?
query=dosomething&page=1" will be intercepted and passed to the
views.py module, with a line in urls.py similar to : "(r'^
$',views.intropage)" (this calls intropage for the main site name,
"mysite.com") - at this point you are NOT trying to match with the ?
query=xxx&page=1 part, just with the url part www.mysite.com/

Then, in views.py, you define a subroutine, which might look something
like this:

def intropage:
        query="some default value"
        page="1"        #(default to page 1)
        if "query" in request.GET:
                query=request.GET("query")
        if "page" in request.GET("page")
                page=request.GET("page")
        #go get the data or whatever you need to do...
        return render_to_response("firstpage.html",locals())    #or whatever you
need...

hope this helps

Simon.


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to