file = models.FileField(upload_to=settings.FILE_PATH)
For uploading a file in django models I used the above line. But For uploading multiple file through django admin model what should I do? I found this But this is for forms. Can I use this for models?
If you want to have multiple files for the same field you would have to write your own field and widget based on the form field you have found otherwise have a separate model for file with a foreign key to your main model and use ModelInline.
models.py
class Page(models.Model):title = models.CharField(max_length=255)class PageFile(models.Model):file = models.ImageField(upload_to=settings.FILE_PATH)page = models.ForeignKey('Page')
admin.py
class PageFileInline(admin.TabularInline):model = PageFileclass PageAdmin(admin.ModelAdmin):inlines = [PageFileInline,]