-
Notifications
You must be signed in to change notification settings - Fork 137
Description
Image uploading in the first inline-level works fine, but in the second level or third level, it gets ignored. Nothing fails and the rest of the fields data get saved fine, but the file upload doesn't happen, the file is not in the server, and the corresponding entry in the database is not stored.
BTW, this is using Django 2.2.1 and code like the following:
models.py
class Course(models.Model):
name = models.CharField(max_length=255)
class Book(models.Model):
name = models.CharField(max_length=255)
course = models.ForeignKey(Course, on_delete=models.CASCADE)
class Lesson(models.Model):
name = models.CharField(max_length=255)
book = models.ForeignKey(Book, on_delete=models.CASCADE)
class LessonImage(models.Model):
image = models.ImageField(null=True, blank=True, upload_to="uploads/")
lesson = models.ForeignKey(Lesson, on_delete=models.CASCADE, related_name='lesson_image')
admin.py
class LessonImageInline(NestedStackedInline):
model = LessonImage
extra = 1
min_num = 0
class LessonInline(NestedStackedInline):
model = Lesson
extra = 1
min_num = 0
inlines = [LessonImageInline]
class BookInline(NestedStackedInline):
model = Book
extra = 1
min_num = 0
inlines = [LessonInline]
@admin.register(Course)
class CourseAdmin(NestedModelAdmin):
list_display = ('created_at', 'updated_at')
list_per_page = 50
inlines = [BookInline]