add prev / next page
This commit is contained in:
parent
ee3b51a24e
commit
85cd14acba
|
@ -91,6 +91,7 @@ def translate(request, model, field, page_no=1):
|
|||
m = models.__getattribute__(model)
|
||||
except AttributeError:
|
||||
return HttpResponse("no such model")
|
||||
page_no = int(page_no)
|
||||
response = []
|
||||
if field not in m._meta.get_all_field_names():
|
||||
return HttpResponse("no such field")
|
||||
|
@ -119,6 +120,10 @@ def translate(request, model, field, page_no=1):
|
|||
})
|
||||
context = RequestContext(request, {
|
||||
'values': response,
|
||||
'has_next': results.has_next(),
|
||||
'next_page': int(page_no) + 1,
|
||||
'previous_page': int(page_no) - 1,
|
||||
'has_previous': results.has_previous(),
|
||||
'page_no': page_no,
|
||||
'num_pages': paginator.num_pages,
|
||||
'model': model,
|
||||
|
|
|
@ -1,6 +1,16 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<style type="text/css">
|
||||
|
||||
#prevButton {
|
||||
float: left;
|
||||
}
|
||||
|
||||
#nextButton {
|
||||
float: right;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript" src="/media/js/jquery.js"></script>
|
||||
<script type="text/javascript" src="/media/js/trans.js"></script>
|
||||
|
||||
|
@ -26,6 +36,14 @@ var trans = {
|
|||
|
||||
{% endfor %}
|
||||
</table>
|
||||
<div id="prevNext">
|
||||
{% if has_previous %}
|
||||
<div id="prevButton"><a href="/trans/{{model}}/{{field}}/{{previous_page}}">Previous</a></div>
|
||||
{% endif %}
|
||||
{% if has_next %}
|
||||
<div id="nextButton"><a href="/trans/{{model}}/{{field}}/{{next_page}}">Next</a></div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue
Block a user