content_type = ContentType.objects.get_for_model(Map)
maps = maps.extra(select=SortedDict([
('member_count', MEMBER_COUNT_SQL),
('topic_count', TOPIC_COUNT_SQL),
]), select_params=(content_type.id,))
을 무엇을 의미하고 ContentType이는 다음과 같습니다이 '콘텐츠 _이'
class ContentType(models.Model):
name = models.CharField(max_length=100)
app_label = models.CharField(max_length=100)
model = models.CharField(_('python model class name'), max_length=100)
objects = ContentTypeManager()
class Meta:
verbose_name = _('content type')
verbose_name_plural = _('content types')
db_table = 'django_content_type'
ordering = ('name',)
unique_together = (('app_label', 'model'),)
def __unicode__(self):
return self.name
def model_class(self):
"Returns the Python model class for this type of content."
from django.db import models
return models.get_model(self.app_label, self.model)
def get_object_for_this_type(self, **kwargs):
"""
Returns an object of this type for the keyword arguments given.
Basically, this is a proxy around this object_type's get_object() model
method. The ObjectNotExist exception, if thrown, will not be caught,
so code that calls this method should catch it.
"""
return self.model_class()._default_manager.using(self._state.db).get(**kwargs)
def natural_key(self):
return (self.app_label, self.model)
내가 알고 싶은 다음 '콘텐츠 _'가 사용되는지?
힌트 : Django의 설명서를 읽으십시오. 그것은 정말로 좋으며 대부분의 질문을 다루고 있습니다. –
뭐가 잘못 되었니? 때때로 설명서를 읽으십시오! –
당신에게 문제가 있습니까? 아들 아? – zjm1126