I have some models in my app,every one is going to have a set of images(n images),in order to handle this i designed these models:
class Gallery(models.Model):
HeadImage = models.ImageField(upload_to="gallery")
class Image(models.Model):
Image = models.ImageField(upload_to="gallery")
Gallery = models.ForeignKey(Gallery, related_name='images')
now every model to have n images,will have a foreignkey to Gallery,like thie:
class Tour(models.Model):
Category=models.ForeignKey(TourCategory)
Name=models.CharField(max_length=100)
Count=models.SmallIntegerField()
PriceUnit=models.ForeignKey(PriceUnit)
Price=models.CharField(max_length=12)
Description=models.TextField()
Status_Choices=(
('a',ugettext_lazy('Activate')),
('d',ugettext_lazy('Deactivate')),
)
StatusType=models.CharField(max_length=1,choices=Status_Choices)
Gallery = models.OneToOneField(Gallery,editable=False)
CHOICES=(
('T',ugettext_lazy('yes')),
('F',ugettext_lazy('no')),
)
isSpecial=models.CharField(max_length=1,choices=CHOICES)
When I add Tour model to admin,I have a combobox for Gallery Field,this combobox doesn’t make sense,like this:

I don’t wanna use other galleries that have been added already,instead I wanna have a formset like this:

Here Head Image is HeadImage field in Gallery model and Image1,Image2,... is an inline Image set for Image model.how can I handle this situation in admin?I wanna ommit that combobox and replace it with this HeadImage and ImageSet.
thanks in advancce
when I change Tour model to this:
class Tour(Gallery):
...
I have some thing like this:

while I need n images for each Tour,so that Head Image is the primary image and more Images(related to Image model) are optional and I’m thinking how to bring a formset of Images beside Head Image Field in Add Tour Form.
do U have any solution?
If the form you’ve provided is accurate, ‘Tour’ doesn’t contain a gallery, it implements a gallery. Therefore, you’ll probably have better luck using Django’s multi-table inheritance. Try something like the following:
And for the love of all that’s holy, read the Python styleguide. Method names should be in lower case with underscores to avoid namespace clashes with classes.