Skip to content

Instantly share code, notes, and snippets.

@a1tus
Created September 4, 2014 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save a1tus/95cd43e8eceffb8ad7fa to your computer and use it in GitHub Desktop.
Save a1tus/95cd43e8eceffb8ad7fa to your computer and use it in GitHub Desktop.
Django 1.7 - DisallowedModelAdminToField
class VideoRelGenericInline(generic.GenericTabularInline):
model = VideoRel
raw_id_fields = ('video',)
class AnotherModelAdmin(admin.ModelAdmin):
inlines = (VideoRelGenericInline,)
admin.site.register(AnotherModel, AnotherModelAdmin)
The exception happens when clicking on the raw_id_fields magnifying glass in the admin, the popup will show the exception.
class Video(models.Model):
youtube_code = models.CharField(max_length=11)
class VideoRel(models.Model):
video = models.ForeignKey('Video')
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField(verbose_name=u'ID объекта')
content_object = generic.GenericForeignKey()
class AnotherModel(models.Model):
videos = generic.GenericRelation('VideoRel')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment