Re: django ORM not compatible with postgres

2009-03-22 Thread Mike Ramirez
On Sunday 22 March 2009 03:59:10 pm Joshua Partogi wrote:
> On Mar 23, 6:56 am, Mike Ramirez  wrote:
> > I think what you want to do with this style is:
> >
> >         obj.user = User.objects.get(username=request.user.username)
> >
> > > or maybe just
> > >
> > > obj.user = request.user
>
> Hi Mike. Thank you very much.
> This syntax works with psycopg2. I wonder why the previous ones that I
> posted works with MySQL.
>

I really can't say.  Maybe one of the contributors can enlighten us on this. 

But as a general rule of thumb, I try to be exact (even to the point of adding 
__exact) in these situations, just so I don't have to worry. 

> Thank you very much anyhow. Really appreciate it.
>

you're welcome.

Mike



-- 
Politics is the ability to foretell what is going to happen tomorrow, next
week, next month and next year.  And to have the ability afterwards to
explain why it didn't happen.
-- Winston Churchill


signature.asc
Description: This is a digitally signed message part.


Re: django ORM not compatible with postgres

2009-03-22 Thread Mike Ramirez
On Sunday 22 March 2009 03:33:41 pm Brian Neal wrote:
> On Mar 22, 2:56 pm, Mike Ramirez  wrote:
> > On Sunday 22 March 2009 09:25:42 am Brian Neal wrote:
> > > But from what you posted, I'm guessing that line needs to read:
> > >
> > > obj.user = User.objects.get(username=request.user)
> >
> > I think what you want to do with this style is:
> >
> >         obj.user = User.objects.get(username=request.user.username)
>
> Yes, my mistake, thanks.
>
> > > or maybe just
> > >
> > > obj.user = request.user
> >
> > yeah, I think this is best.
>
> Agreed.
>
> >Tho if you're the type that sanitizes everything,
> > the upper one is better.
>
> I don't think so. request.user gets set by Django based on cookies, so
> it should be trustworthy as request.user.username.

Agreed, I just meant getting a new/recent user object to work with, which does 
depend on how intricate your system is and if you're updating things based 
off signals that affect what you're doing. example: Other user makes a change 
somewhere, this change, makes updates across multiple tables and you just 
want to be sure that this is the most recent version.

Mike

-- 
This is a good time to punt work.


signature.asc
Description: This is a digitally signed message part.


Re: django ORM not compatible with postgres

2009-03-22 Thread Joshua Partogi



On Mar 23, 6:56 am, Mike Ramirez  wrote:
> I think what you want to do with this style is:
>
>         obj.user = User.objects.get(username=request.user.username)
>
> > or maybe just
>
> > obj.user = request.user

Hi Mike. Thank you very much.
This syntax works with psycopg2. I wonder why the previous ones that I
posted works with MySQL.

Thank you very much anyhow. Really appreciate it.

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django ORM not compatible with postgres

2009-03-22 Thread Brian Neal

On Mar 22, 2:56 pm, Mike Ramirez  wrote:
> On Sunday 22 March 2009 09:25:42 am Brian Neal wrote:
>
>
> > But from what you posted, I'm guessing that line needs to read:
>
> > obj.user = User.objects.get(username=request.user)
>
> I think what you want to do with this style is:
>
>         obj.user = User.objects.get(username=request.user.username)

Yes, my mistake, thanks.

>
> > or maybe just
>
> > obj.user = request.user
>
> yeah, I think this is best.

Agreed.

>Tho if you're the type that sanitizes everything,
> the upper one is better.

I don't think so. request.user gets set by Django based on cookies, so
it should be trustworthy as request.user.username.
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django ORM not compatible with postgres

2009-03-22 Thread Mike Ramirez
On Sunday 22 March 2009 09:25:42 am Brian Neal wrote:
> On Mar 22, 8:15 am, Joshua Partogi  wrote:
> > Dear all,
> >
> > I just encounter this error using pyscopg2 as my db adapter
> > Exception Type:         ProgrammingError
> > Exception Value:        can't adapt
> > Exception Location:
> >         /usr/lib/python2.5/site-packages/django/db/backends/util.py in
> > execute, line 19
> >
> > The query that I'm trying to run from admin is as such:
> >     def save_model(self, request, obj, form, change):
> >         user = User.objects.get(username=request.user)
> >
> > Does anybody know how I can run this with psycopg? What's wrong with
> > these statements? What did I miss here?
>
> It would help if you posted your model.
>
> But from what you posted, I'm guessing that line needs to read:
>
> obj.user = User.objects.get(username=request.user)
>

I think what you want to do with this style is:

obj.user = User.objects.get(username=request.user.username)

 

> or maybe just
>
> obj.user = request.user
>

yeah, I think this is best. Tho if you're the type that sanitizes everything, 
the upper one is better.

> --BN
> --~--~-~--~~~---~--~~
> 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
> django-users+unsubscr...@googlegroups.com For more options, visit this
> group at http://groups.google.com/group/django-users?hl=en
> -~--~~~~--~~--~--~---

Mike

-- 
Didn't I buy a 1951 Packard from you last March in Cairo?


signature.asc
Description: This is a digitally signed message part.


Re: django ORM not compatible with postgres

2009-03-22 Thread Brian Neal

On Mar 22, 8:15 am, Joshua Partogi  wrote:
> Dear all,
>
> I just encounter this error using pyscopg2 as my db adapter
> Exception Type:         ProgrammingError
> Exception Value:        can't adapt
> Exception Location:
>         /usr/lib/python2.5/site-packages/django/db/backends/util.py in
> execute, line 19
>
> The query that I'm trying to run from admin is as such:
>     def save_model(self, request, obj, form, change):
>         user = User.objects.get(username=request.user)
>
> Does anybody know how I can run this with psycopg? What's wrong with
> these statements? What did I miss here?

It would help if you posted your model.

But from what you posted, I'm guessing that line needs to read:

obj.user = User.objects.get(username=request.user)

or maybe just

obj.user = request.user

--BN
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



django ORM not compatible with postgres

2009-03-22 Thread Joshua Partogi

Dear all,


I just encounter this error using pyscopg2 as my db adapter
Exception Type: ProgrammingError
Exception Value:can't adapt
Exception Location:
/usr/lib/python2.5/site-packages/django/db/backends/util.py in
execute, line 19

The query that I'm trying to run from admin is as such:
def save_model(self, request, obj, form, change):
user = User.objects.get(username=request.user)

Does anybody know how I can run this with psycopg? What's wrong with
these statements? What did I miss here?

Thanks very much in advance

-- 
If you can't believe in God the chances are your God is too small.

Read my blog: http://joshuajava.wordpress.com/
Follow me on twitter: http://twitter.com/jpartogi

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---