django admin foreign key to file field and many to many field

Viewed 207

I have a model Teacher which has following data:

class Teacher(models.Model):
    name = models.CharField(max_length=100)
    thumbnail = models.ForeignKey(Thumbnail)

class Thumbnail(models.Model):
    thumbnail = models.FileField(upload_to=upload_to)

class TeacherAdmin(admin.ModelAdmin):
    list_display = ('name',)

Here I want to relate all the thumbnail in my project to Thumbnail field. In my admin it shows me a dropdown of thumbnail while I want to add the thumbnail from admin.

Is it possible that I can upload from admin too?

Also what can I do in the case like :

class Teacher(models.Model):
    name = models.CharField(max_length=100)
    thumbnail = models.ManyToManyField(Thumbnail)

If I want to add multiple Images. The only issue I am having is on admin side. Client side can be handles from regular forms.

Need suggestions and Ideas

0 Answers
Related