Hi all, Some time ago I created 'new feature` ticket <https://code.djangoproject.com/ticket/27580> and Tim Graham asked me to write here to get some feedback on the idea. So here it is.
ContentType model is quite specific, so we could add the subclass of ForeignKey with some specific features. For example, we have a model: class ModelWithContentType(models.Model): ct = ContentTypeField(on_delete=models.CASCADE) In comparison with ForeignKey ContentTypeField will have these features: 1. ModelWithContentType.objects.first().ct will use content types cache 1. ContentTypeField will support lookups on the model classes (on model instances too?): ModelWithContentType.objects.filter(ct=FooModel) vs. ModelWithContentType.objects.filter(ct=ContentType.objects.get_for_model(FooModel)) ModelWithContentType.objects.filter(ct__in=[FooModel, BarModel]) vs. ModelWithContentType.objects.filter(ct__in=[ContentType.objects.get_for_model(model) in [FooModel, BarModel]]) 1. Creation using a model class as a value (not sure if it's useful actually): ModelWithContentType.objects.create(ct=FooModel) Here's ​rough implementation <https://github.com/sir-sigurd/django/tree/contenttype-field-3>. -- You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscr...@googlegroups.com. To post to this group, send email to django-developers@googlegroups.com. Visit this group at https://groups.google.com/group/django-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/7a1bcdcf-bd6c-4258-b0dc-a98492493a53%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.