views:

39

answers:

2

Just wondering because at the moment I am keeping the ImageFields as part of the BlogPost model. If I want to support the potential for 20 images, I have 20 such fields, when often almost 19 of them will never be used. But if I normalize them into a separate model, it's not as intuitive to add images to a post in the admin page, since you have to select the post from a drop down for each image you wish to add, over and over.

Is there a better way to solve this?

+1  A: 

You definitely should create separate model for images.

To edit the images in the admin site you should use inlines. Read the docs here: http://docs.djangoproject.com/en/dev/ref/contrib/admin/#inlinemodeladmin-objects

d.m
This takes care of pulling in the form for adding the image, but if the image is bound to the post, don't we have a chicken before the egg problem?
Rhubarb
Sorry, I'm not sure what do you mean. You will be able to add, as well as edit/delete the image via editing the post instance in admin site.
d.m
+1  A: 

There are already-built image-handling modules for django. For example:

http://code.google.com/p/django-photologue/

http://code.google.com/p/django-fleshin/

eruciform
Looks promising, but definitely overkill for what I need.
Rhubarb