I'm developing a portfolio application. Within this application, I have a model called "Project" which looks something like this:
class Project(models.Model):
...
images = models.ManyToManyField(Image)
...
so, basically, this Project can contain a set of images (any of these images may belong to another Project as well).
Now, what I'd like to add is a way of specifying that one of these "images" is a "lead_image".
So I could add something like this:
class Project(models.Model):
...
images = models.ManyToManyField(Image, related_name='images')
lead_image = models.ForeignKey(Image, related_name='lead_image')
...
However, the problem with this is that in this case, lead_image can be ANY image. What I really want is for it to be one of the "images" that belongs to to this model instance.
I'm thinking that I need to use "ForeignKey.limit_choices_to" argument, but I'm unsure of how to use this...especially since when the model instance is first created, there won't yet be any images in the "images" directory.
Any help would be greatly appeciated.
Doug