Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 June 24, 2010 15:16:07

J.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

About raw sql query


I will need the largest id of table infantregistration.I used raw()
method such as InfantRegistration.objects.raw('SELECT Max(id) FROM
infantregistration').

It returns the error :'Manager' object has no attribute 'raw'.

what can i do now???

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 June 24, 2010 15:22:45

Tom E.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

About raw sql query


On Thu, Jun 24, 2010 at 3:02 PM, Jakir71 <jakirkha...@gmail.com> wrote:
> I will need  the largest id of  table infantregistration.I used raw()
> method such as InfantRegistration.objects.raw('SELECT Max(id) FROM
> infantregistration').
>
> It returns the error :'Manager' object has no attribute 'raw'.
>
> what can i do now???
>http://docs.djangoproject.com/en/1.2/topics/db/sql/#performing-raw-queriesAre you running django 1.2?

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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#3 June 24, 2010 15:37:12

Tran C.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

About raw sql query


but it is only a simple query, why don't you use the query api (aggregate
function...)

On Fri, Jun 25, 2010 at 12:22 AM, Tom Evans <tevans...@googlemail.com>wrote:

> On Thu, Jun 24, 2010 at 3:02 PM, Jakir71 <jakirkha...@gmail.com> wrote:
> > I will need the largest id of table infantregistration.I used raw()
> > method such as InfantRegistration.objects.raw('SELECT Max(id) FROM
> > infantregistration').
> >
> > It returns the error :'Manager' object has no attribute 'raw'.
> >
> > what can i do now???
> >
>
>http://docs.djangoproject.com/en/1.2/topics/db/sql/#performing-raw-queries>
> Are you running django 1.2?
>
> 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<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
>http://groups.google.com/group/django-users?hl=en.
>
>

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#4 June 24, 2010 15:39:03

Daniel R.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

About raw sql query


On Jun 24, 3:02 pm, Jakir71 <jakirkha...@gmail.com> wrote:
> I will need  the largest id of  table infantregistration.I used raw()
> method such as InfantRegistration.objects.raw('SELECT Max(id) FROM
> infantregistration').
>
> It returns the error :'Manager' object has no attribute 'raw'.
>
> what can i do now???

.raw() is new in 1.2.
But if you just want the max ID, you don't want raw anyway. This is
better:

InfantRegistration.objects.order_by('-id').values('id')

--
DR.

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

Board footer

Moderator control

Enjoy the 18th of October
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support