kinda really nOOb question: how to for loop an integer in template?

2006-01-03 Thread EricHsu
hi all, Here is a nOOb question: I'm using the paginate function, I got the total pages, I would like to loop and generate each page number, how can I do that? {% if is_paginated %} {% for page_number in pages %} {{ page_number }} {% endfor %} {% endif %} doesn't se

Re: kinda really nOOb question: how to for loop an integer in template?

2006-01-03 Thread EricHsu
the python way {% for page_number in range(pages) %} doesn't work either... :'(

Re: kinda really nOOb question: how to for loop an integer in template?

2006-01-03 Thread EricHsu
Hi limodou, could you pls be more specific? Thanks!

Re: kinda really nOOb question: how to for loop an integer in template?

2006-01-03 Thread EricHsu
guys, I did it by hacking into django's list_detail.py just add a simply line here: $ svn diff list_detail.py Index: list_detail.py === --- list_detail.py (revision 1813) +++ list_detail.py (working copy) @@ -58,6 +58,7 @@

Re: kinda really nOOb question: how to for loop an integer in template?

2006-01-04 Thread EricHsu
Guys, I created the range0 (0-index) and range1 (1-index filter $ svn diff defaultfilters.py Index: defaultfilters.py === --- defaultfilters.py (revision 1813) +++ defaultfilters.py (working copy) @@ -433,6 +433,14 @@ from p

Re: kinda really nOOb question: how to for loop an integer in template?

2006-01-04 Thread EricHsu
hi all, I've submitted it as a ticket :) http://code.djangoproject.com/ticket/1162

how to search a specific model?

2006-01-07 Thread EricHsu
guys, by reading simon's AbstractSearching: https://simon.bofh.ms/cgi-bin/trac-django-projects.cgi/wiki/AbstractSearching I got my searching for stories work by: 1. settings.py - add: SEARCH_DEFINITIONS = { "foo.apps.bar.search", } INSTALL_APPS = { [snip] 'stuff.search' } 2. url

Re: how to search a specific model?

2006-01-07 Thread EricHsu
btw, I tracked down to the stuff/search/views/generic.py, seem that the kwarg module_list hasn't been passed to the search() funtion from the utils.py, so I have to set the SEARCH_DEFINITION in the settings.py to get the searching work properly. It won't work if I set the search_info_dict like th

Re: how to search a specific model?

2006-01-07 Thread EricHsu
BiG Thanks to hugo! "To have a unified search" - that make things clear now :) I got my site's searching against a single model work with writing lookup_kind function like yours! Now I can search for stories with query_string = 'kind:storys foo bar' and search for users with query_string = 'kind

Re: how to search a specific model?

2006-01-07 Thread EricHsu
Yet another problem :) Could I paginate the search result?

Re: how to search a specific model?

2006-01-07 Thread EricHsu
wOW! I get it done "by writing small wrappers around the generic view"! Thanks A LOT hugo! You've been a great help! I'm going to look into the pagination thing later ;)

Re: Passing more than one arguments to a custom filter

2006-01-09 Thread EricHsu
hi Aggelos, if you pass a tuple to your custom filter, then the arg should become the tuple you could access. I tried something like this (for testing purpose :): {{ story.summary|myfilter:story }} then inside the myfilter, I can: def myfilter(value, arg): story = arg title = story.title

tiny patch to improve the url validating regex

2006-02-09 Thread EricHsu
hey guys, when I tried to save an "https://..."; url into the db, the django's manipulator kept complaining that it was invalid. It is because the django/core/validators.py's url_re is a little bit too simple, the url_re pattern accepts only url begins with "http://";. I've read the RFC3986 whic

Re: tiny patch to improve the url validating regex

2006-02-10 Thread EricHsu
Adrian Holovaty wrote: > Hey Eric, > > Thanks for the pointer on this. I've updated the code in trunk to > accept "https". > > Adrian > My pleasure! I've updated my django source to the latest trunk :) - Eric

Re: Email injection ... What's wrong ?

2006-02-19 Thread EricHsu
Batiste wrote: > Hello, I have some spam incoming in my mailbox... The send_mail > function has to be protected ... What's wrong with my code ? > > def sendMail(request): > from django.core.mail import send_mail > if(request.POST.has_key('email')): > email = request.POST['email'] >

Re: Email injection ... What's wrong ?

2006-02-19 Thread EricHsu
BTW, you may want to try to use pycaptcha (http://sourceforge.net/projects/pycaptcha/) to prevent automated spamming by using your mail form. - Eric --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" gr

Re: Email injection ... What's wrong ?

2006-02-19 Thread EricHsu
I notice a problem with the django's header injection prevention code. It checks only if there's new line (\r or \n) in the header, I guess it should be improved, since when we want to send a utf-8 header, it reaches its limitation - from python's email package email.Header.Header.encode() method

[patch] dealing with unicode charaters (e.g. cjk characters) in tagging stuff

2006-02-23 Thread EricHsu
hello hugo, we're using your tagging code developing our site (in Chinese), while dealing with the tags containing Chinese characters, I found that these charaters were removed by the following line of code in the tagging.py: [code] tagslugs=dict([(slugify(latin1_to_ascii(el.strip())), el.strip(

Re: dealing with unicode charaters (e.g. cjk characters) in tagging stuff

2006-02-23 Thread EricHsu
with this change, ascii characters in the slug field remain as what they are: "Hello World 你好" becomes: hello-world-xe4xbdxa0xe5xa5xbd --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post

possible to keep elements' order while get_list(id__in=[...])?

2006-03-06 Thread EricHsu
hi all, giving a id list in which the elements' order is important, for example: category_id_list = [1, 4, 9, 6] is it possible to make sure that categorys.get_list(id__in=category_id_list) returns category object list in the same order as category_id_list? that is, make sure the returned list l