Posts

Showing posts from 2009

How to add pagination to django comments for your model

First step is import Comment and ContentType to your view like below from django.contrib.comments.models import Comment from django.contrib.contenttypes.models import ContentType Second step is defining your model which you want to paginate its comments content_type_id= ContentType.objects.get_for_model( YOUR_MODEL_NAME ) Last get comments of specific instance of your model class with defining object_pk as filter parameter comments = Comment.objects.filter(content_type=content_type_id,object_pk=quote_id) here is complete view code from django.core.paginator import Paginator, InvalidPage, EmptyPage from django.contrib.comments.models import Comment from django.contrib.contenttypes.models import ContentType def quote_show_page(request,quote_id): quote = get_object_or_404(Quote, id=quote_id) content_type_id=ContentType.objects.get_for_model(Quote) comments = Comment.objects.filter(content_type=content_type_id,object_pk=quote_id) paginator = Paginator(comments, 5) # Show 5 comments pe

glade and pygtk

fantastic video tutorial about gtk glade python very beginning level

error: invalid Python installation

if you are getting same exception below you have not a development version of python installed on your suse error: invalid Python installation: unable to open /usr/lib/python2.5/config/Makefile (No such file or directory) find devel package of your python version specific and install it

interesting python functions

# send each member of range(5) sequence to p function which is simply printing it's argument def p(x): print x map(p,range(5)) #filter sequence for given condition seq=[2,22,22.2] z=filter(lambda x:x>2, seq) print z #take first two argument of sequence as x,y then apply x*y , take result of this as a new first argument take 3rd argument which is 3 here as a new second argument and continue to process till the end of sequence numbers=[1,2,3,4,5] print reduce(lambda x,y:x*y,numbers) here are the outputs of functions above 0 1 2 3 4 [22, 22.199999999999999] 120 -------------------------------------------------- Python Environment -------------------------------------------------- version = 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit (Intel)] platform = win32

python toolbox

useful toolbox links for python http://mashable.com/2007/10/02/python-toolbox/

pyscripter

pyscripter really really fantastic ide for python http://mmm-experts.com/Products.aspx?ProductId=4

Sql Tuning Teknikleri Sunumu

Turkcell Teknoloji 2009 çalıştayı Sql Tuning Teknikleri sunumum 21Subat_Sql_Tuning_Techniques_Presentation [English Content] Turkcell Teknoloji , Hasan Tonguç Yılmaz ve çalıştayı gerçekleştirmemizde emeği geçen herkese teşekkürler. Sunumda kullanılan kaynaklar - references Christian Antognini - Troubleshooting Oracle Performance optimizermagic.blogspot.com Oracle Performance Tuning Guide 10.2