On Nov 3, 2013, at 2:43 PM, Aamu Padi <aamupadi@gmail.com> wrote:
Thank you for the reply Lee. But could please elaborate a little more. :)On Mon, Nov 4, 2013 at 2:48 AM, Lee Hinde <leehinde@gmail.com> wrote:
I recently needed a similar thing (one item out of a table being _the_ thing) and decided that host table was the wrong place to store it. It needs to be in the other table, in this case, your user table should have a field that is the key of the profile picture.
On Nov 3, 2013, at 12:23 PM, Aamu Padi <aamupadi@gmail.com> wrote:
> How to make a model with a yes/no field, if yes that particular object (image) will be used as the background, and no other image will be selected.
>
> I have come with this model:
>
> class BackgroundImage(models.Model):
> user = models.ForeignKey(user)
> caption = models.CharField(max_length=200)
> image = models.ImageField(upload_to=get_upload_file_name)
> using_image = models.BooleanField()
>
> But with this I can select all of them, and not only one.
>
> Lets take an example of profile picture. A user can have many images, but he can only select one as a profile picture. So, that if he selects one, the other will be un-select itself.
> Hope everybody understood what I mean. Please ask me if didn't understood. Also please correct me if my model is not correct. Thank you!
>
No comments:
Post a Comment