﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
2488	get_for_model building bad SQL	jayklehr	Adrian Holovaty	"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:
{{{
#!python
# 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)
[<TaggedItem: clearish>, <TaggedItem: shiny>]
}}}

When I run this line:

{{{
#!python
ctype = ContentType.objects.get_for_model(quartz)
}}}

I get this SQL built:

{{{
#!sql
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.)"	defect	closed	Database layer (models, ORM)	dev	normal	invalid			Unreviewed	0	0	0	0	0	0
