Sunday, November 3, 2013

Re:

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:

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!
>

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.



--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/D75EAE65-8A05-4E92-9638-DD89D852800F%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAHSNPWtWQfDH%2BzXTtqmCTWS1ZwoowKPQqiFvr7yL2%3DOr1xMLdQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment