Created
September 4, 2014 20:27
-
-
Save a1tus/95cd43e8eceffb8ad7fa to your computer and use it in GitHub Desktop.
Django 1.7 - DisallowedModelAdminToField
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class VideoRelGenericInline(generic.GenericTabularInline): | |
model = VideoRel | |
raw_id_fields = ('video',) | |
class AnotherModelAdmin(admin.ModelAdmin): | |
inlines = (VideoRelGenericInline,) | |
admin.site.register(AnotherModel, AnotherModelAdmin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The exception happens when clicking on the raw_id_fields magnifying glass in the admin, the popup will show the exception. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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