On Fri, Sep 3, 2010 at 5:05 PM, jean polo <josiano....@googlemail.com> wrote:
> ok sorry if I used a bad example with id..
> I meant something like:
> xxxxxx?bla=1,2,3,4
>
> I got it working by using a special field ('bla') in my form which is
> a CharField
> then I parse bla:
> arr = request.GET.get('bla').split(',')
> if all items of arr are integers, I have my array of 'bla' =)
>
> cheers,
> _y
>

Danger Will Robinson!

You are now departing from convention, or how everyone else does
things. Whilst this may work for a while, you will quickly get annoyed
that you cant do simple things easily, like generating URLs of that
format.

If your URL looks like this:

xxxxx?bla=1&bla=2&bla=3&bla=4

then you get your list of bla like so:

arr = request.GET.getlist('bla')

You can then regenerate your URL easily using a QueryDict:

>>> from django.http import QueryDict
>>> q=QueryDict('', mutable=True)
>>> q.setlist('blah', ['1', '2', '3', '4'])
>>> q.urlencode()
'blah=1&blah=2&blah=3&blah=4'

However, you now can't do any of this, and will have to hand craft
your URLs, just because you don't like convention. Enjoy.


Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.

Reply via email to