Multiple Image Field in a model

2,216 views
Skip to first unread message

NavaTux

unread,
Sep 26, 2011, 10:02:51 AM9/26/11
to Django users
Hi all,

I have a filed(ImageField) in my model.Also I want to have
multiple ImageFields.How to have more than one ImageFields only in
django model.Is there any need to derive that ImageField as a seperate
new model which holds as a foreign key of another one?

This is my model:

class Report(models.Model):
name = models.CharField(max_length=1024)
data = models.TextField()
image = models.ImageField(upload_to=settings.IMAGE_UPLOAD_PATH,
blank=True, null=True)

I need to display atleast 4 imagefields for this model object?

Philip Mountifield

unread,
Sep 26, 2011, 10:14:21 AM9/26/11
to django...@googlegroups.com
I would put the images in a seperate model such as "ReportImage" and
make a foreign key to "Report", and finally I'd use the "inlines" admin
feature for ReportImages to display them on the same page as the report.

Phil


--

Philip Mountifield
Formac Electronics Ltd
tel +44 (0) 1225 837333
fax +44 (0) 1225 430995

pmount...@formac.net
www.formac.net
www.telgas.net

NavaTux

unread,
Sep 27, 2011, 9:49:08 AM9/27/11
to Django users
Thanks I have done the same way before seeing this valuable one.

Let me ask you one more? ..Need to do some extra functioalities like
the effects of Uploading file in gmail like that in django? any
suggestions?

On Sep 26, 7:14 pm, Philip Mountifield <pmountifi...@formac.net>
wrote:
> pmountifi...@formac.netwww.formac.netwww.telgas.net

Tom Evans

unread,
Sep 27, 2011, 10:03:25 AM9/27/11
to django...@googlegroups.com
On Tue, Sep 27, 2011 at 2:49 PM, NavaTux <navane...@gmail.com> wrote:
> Thanks I have done the same way before seeing this valuable one.
>
> Let me ask you one more? ..Need to do some extra functioalities like
> the effects of Uploading file in gmail like that in django? any
> suggestions?
>

Google is full of tips and hints on things like that. Try to search
for 'AJAX file upload django', and remember that we aren't a human
interface to google for you :)

Cheers

Tom

Yash Chandra verma

unread,
Mar 31, 2020, 7:18:10 PM3/31/20
to Django users
This is how exactly you could solve it. Multiple FIle Upload
Reply all
Reply to author
Forward
0 new messages