some strange paginator behavior
hello, the following code produces a table with 15 rows as expected. the same code with "hits=paginator.hits" without comment sign results in: Exception Type: TypeError Exception Value:count() takes exactly one argument (0 given) paginate_by = 15 paginator = ObjectPaginator(TMergeDoc().by_categories(), paginate_by) page = int(request.GET.get('page', 0)) objects = paginator.get_page(page) #hits=paginator.hits return render_to_response('show_categories/index.html', {'objects': objects, 'paginator':paginator }) if I try to see the paginator object in the web view, there is *no* object. how does this work? the paginator code inside a method without custom sql works fine -> I'm able to use the paginator attributes. thank you, robert --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Pagination with Custom Views
holy ... , how stupid. but it led not to the solution, which is: TMergeDoc().by_categories() I had to instantiate the object, of course. Now there are some paginator problems I have to analyze. thank you very much so far! robert --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Pagination with Custom Views
hello, I'm desperately searching for a solution as described here (paginator + costom sql): http://groups.google.com/group/django-users/browse_frm/thread/1aa04d3ab8fc9203/ab1384a82c9d5508#ab1384a82c9d5508 and here: http://groups.google.com/group/django-users/browse_frm/thread/d6690c92c5b7347e/7985a43df0f8b43a#7985a43df0f8b43a ... and I still can't find out, what's wrong. Maybe you are able to answer... thank you in advance! robert --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: custom sql, method definition and views.py
> > Hello, > > if there is a method definition in the models.py like this: > > > > class TMergeDoc(models.Model): > > > > def by_categories(self): > > from django.db import connection > > ... > > return objects > > > > what is the corresponding call in the views.py? > > objects = TMergeDoc.objects.by_category() > > doesn't work ('Manager' object has no attribute 'by_category'), > > objects = TMergeDoc.objects.all().by_category() > > either. > > > > thank you in advance, > > robert > > > by_categories is a method of TMergeDoc > Have you try > import models > objects = TMergeDoc.by_categories() > yes, I did... Exception Type: AttributeError Exception Value:type object 'TMergeDoc' has no attribute 'by_category' any idea? thank you, robert --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
custom sql, method definition and views.py
Hello, if there is a method definition in the models.py like this: class TMergeDoc(models.Model): def by_categories(self): from django.db import connection ... return objects what is the corresponding call in the views.py? objects = TMergeDoc.objects.by_category() doesn't work ('Manager' object has no attribute 'by_category'), objects = TMergeDoc.objects.all().by_category() either. thank you in advance, robert --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Custom SQL/Paginator problems
> Hello soundseeker! > On Mon, 06 Nov 2006 02:20:25 -0800 you wrote: > > > def show_categories(request, col, direction): > > paginate_by = 15 > > paginator = > > ObjectPaginator(VMergeDocsInfo.objects.all().by_categories(), > > paginate_by) > > Maybe something like this: VMergeDocsInfo.objects.by_categories()? > hello grigory, that's what happen: Exception Type: AttributeError Exception Value:'Manager' object has no attribute 'by_categories' thank you, robert --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Custom SQL/Paginator problems
Hello, here's a django/python newbie problem, which I could not resolve after spending some time with reading and testing. Assuming a method in my models.py class VMergeDocsInfo(models.Model): .. def by_categories(self): from django.db import connection cursor = connection.cursor() cursor.execute("SELECT DISTINCT doc_title FROM t_merge_docs") return [row for row in cursor.fetchall()] ... and following code in the views.py def show_categories(request, col, direction): paginate_by = 15 paginator = ObjectPaginator(VMergeDocsInfo.objects.all().by_categories(), paginate_by) produces: AttributeError Exception Value: 'QuerySet' object has no attribute 'by_categories' ok, let's go further: def show_categories(request, col, direction): paginate_by = 15 paginator = ObjectPaginator(VMergeDocsInfo.objects.all()[0].by_categories(), paginate_by) objects = paginator.get_page(page) return render_to_response('show_categories/index.html', {'objects': objects }) .. (what means the '[0]') after .all?) shows the paginated table in the mentioned way but leads to another problem: return render_to_response('show_categories/index.html', {'objects': objects, 'hits' : paginator.hits }) TypeError Exception Value: count() takes exactly one argument (0 given) Every access to the paginator attributes results in this exception. Where's the crux, what am I doing wrong? Thank you in advance, robert --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
custom sql/paginator problems
hi, some newbie questions here... after spending much time with reading/testing I still have no solution; some help is needed and appreciated. here's the problem: having a class definition with a custom sql statement: class VMergeDocsInfo(models.Model): def by_categories(self): from django.db import connection cursor = connection.cursor() cursor.execute("SELECT DISTINCT doc_title FROM t_merge_docs") return [row for row in cursor.fetchall()] .. ... and a view definition with: paginate_by = 15 paginator = ObjectPaginator(VMergeDocsInfo.objects.all().by_categories(), paginate_by) results in: AttributeError Exception Value:'QuerySet' object has no attribute 'by_categories' following is ok: paginator = ObjectPaginator(VMergeDocsInfo.objects.all()[0].by_categories(), paginate_by) objects = paginator.get_page(page) return render_to_response('show_categories/index.html', {'objects': objects}) but now comes the next problem: return render_to_response('show_categories/index.html', {'objects': objects, 'hits' : paginator.hits}) produces TypeError Exception Value:count() takes exactly one argument (0 given) why? what's wrong with the paginator? thank you in advance, robert --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---