Re: Pagination of more than one field

2011-09-07 Thread OC
works as a charm
thanks

On 7 ספטמבר, 17:05, Malcolm Box  wrote:
> On 7 September 2011 14:57, OC  wrote:
>
>
>
>
>
> > Thank you very much for your reply,
> > I changed it but I guess Im doing something wrong cause it still
> > doesnt work:
> > It tries to go to the right page now, but provides nothing although I
> > know there's more than one page:
>
> > in views.py
> > movies_page= int(request.GET.get('page','1'))
> >    try:
> >        moviesp = movpaginator.page(movies_page)...
>
> > in the template:
> >       {% if actors.has_previous %}
> >                                 > src="{{ MEDIA_URL }} images/preview.png">
> >                        {% else %}
>
> > You're setting the movies_page request parameter in the URL you're
>
> generating, but you're reading the *page* request parameter in the view
> function.
>
> Change to "movies_page = int(request.GET.get('movies_page', 1))" and it
> should work-הסתר טקסט מצוטט-
>
> -הראה טקסט מצוטט-

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Pagination of more than one field

2011-09-07 Thread Malcolm Box
On 7 September 2011 14:57, OC  wrote:

> Thank you very much for your reply,
> I changed it but I guess Im doing something wrong cause it still
> doesnt work:
> It tries to go to the right page now, but provides nothing although I
> know there's more than one page:
>
> in views.py
> movies_page= int(request.GET.get('page','1'))
>try:
>moviesp = movpaginator.page(movies_page)...
>
> in the template:
>   {% if actors.has_previous %}
> src="{{ MEDIA_URL }} images/preview.png">
>{% else %}
>
>
> You're setting the movies_page request parameter in the URL you're
generating, but you're reading the *page* request parameter in the view
function.

Change to "movies_page = int(request.GET.get('movies_page', 1))" and it
should work

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Pagination of more than one field

2011-09-07 Thread OC
Thank you very much for your reply,
I changed it but I guess Im doing something wrong cause it still
doesnt work:
It tries to go to the right page now, but provides nothing although I
know there's more than one page:

in views.py
movies_page= int(request.GET.get('page','1'))
try:
moviesp = movpaginator.page(movies_page)...

in the template:
  {% if actors.has_previous %}

{% else %}


On 7 ספטמבר, 15:53, Malcolm Box  wrote:
> On 7 September 2011 08:25, OC  wrote:
>
>
>
>
>
> > also attaching relevant parts of view.py:
>
> >  movpagin = Paginator(movies, 12)
>
> >    page = int(request.GET.get('page','1'))
> >    try:
> >        moviesp = movpagin.page(page)
> >    except PageNotAnInteger:
> >        # If page is not an integer, deliver first page.
> >        moviesp = movpagin.page(1)
> >    except EmptyPage:
> >        # If page is out of range (e.g. ), deliver last page of
> > results.
> >        moviesp = movpagin.page(movpagin.num_pages)
>
> >    actpagin = Paginator(actors, 8)
>
> >    page = int(request.GET.get('page','1'))
>
> There's the problem right there. You're using the same page variable for
> both sides, so inevitably you'll find they move together.
>
> Put the movies page into a variable called movie_page, and the actors into
> actor_page. Update your links in the template to use the right query for the
> prev/next and all should work fine.
>
> Malcolm-הסתר טקסט מצוטט-
>
> -הראה טקסט מצוטט-

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Pagination of more than one field

2011-09-07 Thread Malcolm Box
On 7 September 2011 08:25, OC  wrote:

> also attaching relevant parts of view.py:
>
>
>  movpagin = Paginator(movies, 12)
>
>page = int(request.GET.get('page','1'))
>try:
>moviesp = movpagin.page(page)
>except PageNotAnInteger:
># If page is not an integer, deliver first page.
>moviesp = movpagin.page(1)
>except EmptyPage:
># If page is out of range (e.g. ), deliver last page of
> results.
>moviesp = movpagin.page(movpagin.num_pages)
>
>actpagin = Paginator(actors, 8)
>
>page = int(request.GET.get('page','1'))
>

There's the problem right there. You're using the same page variable for
both sides, so inevitably you'll find they move together.

Put the movies page into a variable called movie_page, and the actors into
actor_page. Update your links in the template to use the right query for the
prev/next and all should work fine.

Malcolm

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Pagination of more than one field

2011-09-07 Thread bruno desthuilliers
On Sep 6, 4:41 pm, Yaşar Arabacı  wrote:
> I think your question can be solved with javascript and ajax, rather than
> with django. How is your knowledge in that area?


This can definitly be resolved with Django, and it's always better to
have something working without js / ajax when possible (you can then
add js / ajax afterward).

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Pagination of more than one field

2011-09-07 Thread OC
also attaching relevant parts of view.py:


  movpagin = Paginator(movies, 12)

page = int(request.GET.get('page','1'))
try:
moviesp = movpagin.page(page)
except PageNotAnInteger:
# If page is not an integer, deliver first page.
moviesp = movpagin.page(1)
except EmptyPage:
# If page is out of range (e.g. ), deliver last page of
results.
moviesp = movpagin.page(movpagin.num_pages)

actpagin = Paginator(actors, 8)

page = int(request.GET.get('page','1'))
try:
actp = actpagin.page(page)
except PageNotAnInteger:
# If page is not an integer, deliver first page.
actp = actpagin.page(1)
except EmptyPage:
# If page is out of range (e.g. ), deliver last page of
results.
actp = actpagin.page(actpagin.num_pages)
cntx = RequestContext(request,{
'actors':actp,
'movies' : moviesp,
})
return render_to_response('display.html',cntx)


On 7 ספטמבר, 08:54, OC  wrote:
> I am familiar with js but not with ajax
> I thought that django supports these kind of matters ... isnt it
> trivial?
>
> Attached the code
> Please advise
>
> {% for movie in movies.object_list %#}
>                 
>                                         "whitestripe" "bluestripe" %}>{{movie.name}} 
>                   
>
>                 {% endfor %}
>
>                 
>                         
>                         {% if movies.has_previous %}
>                                 
>                         {% else %}
>                                 
>                         {% endif %}
>
>                         
>                         {% for page_number in
> movies.paginator.page_range %}
>                                 {% if page_number == movies.number %}
>                                          class="pagination_current">{{ movies.number }}
>                                 {% else %}
>                                         {{ page_number }}
>                                 {% endif %}
>                         {% endfor %}
>
>                       
>                         {% if movies.has_next %}
>                                 
>                         {% else %}
>                                 
>                         {% endif %}
>                 
>         
>
>             {% for actor in actors.object_list %}
>                         {% load parseval %}
>                                 {% autoescape off %}
>                         
>                                 
>                                          id="box_header">{{ actor.pt|upper }}
>                                 
>                         
>                                 {% endautoescape %}
>                 {% empty %}
>                 {% endfor %}
>          
>                         
>                         {% if actors.has_previous %}
>                                 
>                         {% else %}
>                                 
>                         
>                         {% for page_number in
> actors.paginator.page_range %}
>                                 {% if page_number == actors.number %}
>                                          class="pagination_current">{{ actors.number }}
>                                 {% else %}
>                                         {{ page_number }}
>                                 {% endif %}
>                         {% endfor %}
>                         
>                         {% if actors.has_next %}
>                                 
>                         {% else %}
>                                 
>                         {% endif %}
>                 
>
> On 6 ספטמבר, 17:41, Yaşar Arabacı  wrote:
>
>
>
> > I think your question can be solved with javascript and ajax, ratherthan
> > with django. How is your knowledge in that area?
>
> > 2011/9/6 OC 
>
> > > Hi,
>
> > > I am new to django and I have apaginationquestion:
> > > In my web page I need to display 2 query results of two different
> > > tables
> > > Each result is displayed in a different div in the same page.
>
> > > How can I implement "multiple"paginationmeaning that each result is
> > > displayed in its own panel and has its own previous and next buttons
> > > but doesn't affect the other's query result?
>
> > > For instance - I have a panel of movies, display 10 each time, and
> > > have a prev and next buttons dedicated to the movies only
> > > Plus
> > > In the same page, I have a panel of actors, display 10 each time, and
> > > have a prev and next buttons dedicated to the actors only
>
> > > My current (wrong) implementation is
> > > usepaginationfor the both of them but when pressing the next/
> > > previous button ofone- it affects (as expected) the display of the
> > > otheronebecause the entire page has changed.
>
> > > Thanks in advance,
> > > Osnat
>
> > > --
> > > You received 

Re: Pagination of more than one field

2011-09-06 Thread OC
I am familiar with js but not with ajax
I thought that django supports these kind of matters ... isnt it
trivial?

Attached the code
Please advise

{% for movie in movies.object_list %#}

   {{movie.name}} 
  

{% endfor %}



{% if movies.has_previous %}

{% else %}

{% endif %}


{% for page_number in
movies.paginator.page_range %}
{% if page_number == movies.number %}
{{ movies.number }}
{% else %}
{{ page_number }}
{% endif %}
{% endfor %}

  
{% if movies.has_next %}

{% else %}

{% endif %}



{% for actor in actors.object_list %}
{% load parseval %}
{% autoescape off %}


{{ actor.pt|upper }}


{% endautoescape %}
{% empty %}
{% endfor %}
 

{% if actors.has_previous %}

{% else %}


{% for page_number in
actors.paginator.page_range %}
{% if page_number == actors.number %}
{{ actors.number }}
{% else %}
{{ page_number }}
{% endif %}
{% endfor %}

{% if actors.has_next %}

{% else %}

{% endif %}



On 6 ספטמבר, 17:41, Yaşar Arabacı  wrote:
> I think your question can be solved with javascript and ajax, rather than
> with django. How is your knowledge in that area?
>
> 2011/9/6 OC 
>
>
>
>
>
> > Hi,
>
> > I am new to django and I have a pagination question:
> > In my web page I need to display 2 query results of two different
> > tables
> > Each result is displayed in a different div in the same page.
>
> > How can I implement "multiple" pagination meaning that each result is
> > displayed in its own panel and has its own previous and next buttons
> > but doesn't affect the other's query result?
>
> > For instance - I have a panel of movies, display 10 each time, and
> > have a prev and next buttons dedicated to the movies only
> > Plus
> > In the same page, I have a panel of actors, display 10 each time, and
> > have a prev and next buttons dedicated to the actors only
>
> > My current (wrong) implementation is
> > use pagination for the both of them but when pressing the next/
> > previous button of one - it affects (as expected) the display of the
> > other one because the entire page has changed.
>
> > Thanks in advance,
> > Osnat
>
> > --
> > 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
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
> --http://yasar.serveblog.net/-הסתר טקסט מצוטט-
>
> -הראה טקסט מצוטט-

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Pagination of more than one field

2011-09-06 Thread Yaşar Arabacı
I think your question can be solved with javascript and ajax, rather than
with django. How is your knowledge in that area?

2011/9/6 OC 

> Hi,
>
> I am new to django and I have a pagination question:
> In my web page I need to display 2 query results of two different
> tables
> Each result is displayed in a different div in the same page.
>
> How can I implement "multiple" pagination meaning that each result is
> displayed in its own panel and has its own previous and next buttons
> but doesn't affect the other's query result?
>
> For instance - I have a panel of movies, display 10 each time, and
> have a prev and next buttons dedicated to the movies only
> Plus
> In the same page, I have a panel of actors, display 10 each time, and
> have a prev and next buttons dedicated to the actors only
>
> My current (wrong) implementation is
> use pagination for the both of them but when pressing the next/
> previous button of one - it affects (as expected) the display of the
> other one because the entire page has changed.
>
> Thanks in advance,
> Osnat
>
> --
> 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
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
http://yasar.serveblog.net/

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Pagination of more than one field

2011-09-06 Thread OC
Hi,

I am new to django and I have a pagination question:
In my web page I need to display 2 query results of two different
tables
Each result is displayed in a different div in the same page.

How can I implement "multiple" pagination meaning that each result is
displayed in its own panel and has its own previous and next buttons
but doesn't affect the other's query result?

For instance - I have a panel of movies, display 10 each time, and
have a prev and next buttons dedicated to the movies only
Plus
In the same page, I have a panel of actors, display 10 each time, and
have a prev and next buttons dedicated to the actors only

My current (wrong) implementation is
use pagination for the both of them but when pressing the next/
previous button of one - it affects (as expected) the display of the
other one because the entire page has changed.

Thanks in advance,
Osnat

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.