Re: get_for_model building bad SQL?

2006-08-05 Thread Jay Klehr

Malcom,  sorry about the reply, I use my email client to interact with 
google group and pressed reply so that it would use the right account to 
send from (since I'm not subscribed with my default account).  Won't 
happen again now that I know google groups is smarter than I though. ;)

I created a ticket:  http://code.djangoproject.com/ticket/2488

Thanks,

Jay

Malcolm Tredinnick wrote:
> Hi Jay,
>
> Please start a new thread for a new topic, rather than replying on an
> existing thread. Makes things easier to track both in threaded email
> clients and in the web view. Thanks. :-)
>
>   

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: get_for_model building bad SQL?

2006-08-05 Thread Malcolm Tredinnick

Hi Jay,

Please start a new thread for a new topic, rather than replying on an
existing thread. Makes things easier to track both in threaded email
clients and in the web view. Thanks. :-)

On Fri, 2006-08-04 at 23:06 -0600, Jay Klehr wrote:
[...]
> When I run this line:
> 
> ctype = ContentType.objects.get_for_model(quartz)
> 
> 
> I get this SQL built:
> 
> SELECT 
> `django_content_type`.`id`,`django_content_type`.`name`,`django_content_type`.`app_label`,`django_content_type`.`model`
>  
> FROM `django_content_type` WHERE (`django_content_type`.`model` = quartz 
> AND `django_content_type`.`app_label` = myapp)

Looks like a bug. I can replicate this with other database backends as
well. Can you file a ticket for it so it doesn't get lost, please?
Shouldn't be too hard to fix.

Thanks,
Malcolm


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



get_for_model building bad SQL?

2006-08-04 Thread Jay Klehr

Hello,

Running Django's dev server on mysql 4.1.20 and trying to make use of 
the get_for_model method from the ContentTypes package to get the 
content type of a model (using the examples laid out in the 
GenericForeignKey documentation 
http://www.djangoproject.com/documentation/models/generic_relations/ )

Here's the example code from the documentation:

# However, excluding GenericRelations means your lookups have to be a 
bit more
# explicit.
>>> from django.contrib.contenttypes.models import ContentType
>>> ctype = ContentType.objects.get_for_model(quartz)
>>> TaggedItem.objects.filter(content_type__pk=ctype.id, 
>>> object_id=quartz.id)
[, ]


When I run this line:

ctype = ContentType.objects.get_for_model(quartz)


I get this SQL built:

SELECT 
`django_content_type`.`id`,`django_content_type`.`name`,`django_content_type`.`app_label`,`django_content_type`.`model`
 
FROM `django_content_type` WHERE (`django_content_type`.`model` = quartz 
AND `django_content_type`.`app_label` = myapp)

MySQL doesn't like having no ticks around the two values 'quartz' and 
'myapp' in this case. (My app is actually named "database" right now, 
which is a mysql reserved word as well.)

In the example docs quartz is actually an instance of a model, but in 
mine I'm doing something like this:

from site.myapp.models import MyModel

ctype = ContentType.objects.get_for_model(MyModel)

Which would generate sql similar to above, but "quartz" would be 
replaced with "mymodel".

I suspect I shouldn't be using it this way, but seeing SQL like that 
being run also concerned me.

Any ideas?

Jay

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---