0

i want to do paging. but i only want to know the current page number, so i will call the webservice function and send this parameter and recieve the curresponding data. so i only want to know how can i be aware of current page number? i'm writing my project in django and i create the page with xsl. if o know the page number i think i can write this in urls.py:

url(r'^ask/(\d+)/$',
        'ask',
        name='ask'),

and call the function in views.py like:

ask(request, pageNo)

but i don't know where to put pageNo var in html page. (so fore example with pageN0=2, i can do pageNo+1 or pageNo-1 to make the url like 127.0.0.01/ask/3/ or 127.0.0.01/ask/2/). to make my question more cleare i want to know how can i do this while we don't have any variables in html? sorry for my crazy question, i'm new in creating website and also in django. :">

i'm creating my html page with xslt. so i send the total html page. (to show.html which contains only {{str}} )

def ask(request:
    service = GetConfigLocator().getGetConfigHttpSoap11Endpoint()
    myRequest = GetConfigMethodRequest()
    myXml = service.GetConfigMethod(myRequest)
    myXmlstr = myXml._return
    styledoc = libxml2.parseFile("ask.xsl")
    style = libxslt.parseStylesheetDoc(styledoc)
    doc = libxml2.parseDoc(myXmlstr)
    result = style.applyStylesheet(doc, None)
    out = style.saveResultToString( result )
    ok =  mark_safe(out)
    style.freeStylesheet()
    doc.freeDoc()
    result.freeDoc()       
    return render_to_response("show.html", {
          'str': ok,           
            }, context_instance=RequestContext(request))

i'm not working with db and i just receive xml file to parse it. so i don't have contact_list = Contacts.objects.all(). can i still use this way? should i put the first parameter inpaginator = Paginator(contact_list, 25) blank?

4

1 回答 1

0

如果您使用标准 django paginator,则将您发送到 url http://example.com/?page=N,其中N- 您的页面编号所以,

# urls.py
url('^ask/$', 'ask', name='viewName'),

您可以在视图中获取页码:

# views.py
def ask(request):
  page = request.GET.get('page', 1)
于 2012-09-14T08:55:13.177 回答