115 | | self.object_id_field_name = kwargs.pop("object_id_field", "object_id") |
116 | | self.content_type_field_name = kwargs.pop("content_type_field", "content_type") |
| 122 | #self.object_id_field_name = kwargs.pop("object_id_field", "object_id") |
| 123 | #self.content_type_field_name = kwargs.pop("content_type_field", "content_type") |
| 124 | from_field = kwargs.pop('from', None) |
| 125 | to_generic_fks = [field for field in getattr(to._meta, 'generic_foreign_keys', []) |
| 126 | if (field.__class__ == GenericForeignKey |
| 127 | and (from_field and (from_field == field.name) or True))] |
| 128 | exc_args = {'named': from_field and (" named '%s'" % from_field) or "", |
| 129 | 'to_model': to._meta.object_name, |
| 130 | 'specify': from_field and "" or ": Specify one with the 'from' argument."} |
| 131 | if len(to_generic_fks) == 0: |
| 132 | raise Exception("No GenericForeignKey field%(named)s on '%(to_model)s' to relate to." % exc_args) |
| 133 | elif len(to_generic_fks) > 1: |
| 134 | raise Exception("Multiple GenericForeignKey fields%(named)s on '%(to_model)s' to relate to%(specify)s" % exc_args) |