On 12/7/05, Simon Willison <[EMAIL PROTECTED]> wrote:


On 6 Dec 2005, at 21:00, Adrian Holovaty wrote:

> Thoughts?
>
> http://code.djangoproject.com/wiki/RemovingTheMagic

I really like almost all of it. My one hang-up is this:

Person.objects.get_list(Person.q.first_name == 'Adrian')

I like the Person.objects bit, but I'm not so keen on
Person.q.first_name - it's pretty verbose.

+1 on the proposal but for the bit you mentioned. My head is turning inside out trying to make sense of Person.objects.get_list(Person.q.first_name == 'Adrian'): Person.q.first_name == 'Adrian' is an _expression_ and should return True or False, so I am thinking == is a typo and you meant =, in which case you are trying to use keyword argumet, but how? What is type( Perso.q.first_name)?
>>> def f(a):
...    print a
...
>>> k = 'a'
>>> f(k=10)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: f() got an unexpected keyword argument 'k'
Am I missing something obvious? Please elaborate someone. People .get_list(first_name__exact='Adrian' ) sounds better to me.

How about supporting an SQL where clause, as seen in Rails?

Person.objects.get_where('first_name = %s and last_name = %s',
'Adrian', 'Holovaty')

Not exactly the same but http://www.djangoproject.com/documentation/db_api/#where-tables talks about something that is very similer.

--
Amit Upadhyay
Blog: http://www.rootshell.be/~upadhyay
+91-9867-359-701

Reply via email to