Re: Model to select only 1 object from multiple objects
Thank you. I hope I can walk through now. :)
On Mon, Nov 4, 2013 at 7:43 PM, Ruturaj Dhekane <ruturajmd@gmail.com> wrote:
Your model can work. But I think the model there is an alternate way to create this model.The way I might design this is have a profile modelProfile = name, birth date, location, favorite books, friends, ProfilePicture (foreignKey)ProfilePicture = image, captionSo now, you can have multiple profile pictures and the profile will point to that profile picture which needs to be shown. Hope this helps.To do it the way you are doing - you need to make sure that first all User=X have set using_image=false. Then set the particular used using_image=true. Then you can retrieve the unique photo for every user by filtering on using_image = true This needs to be done in code rather than in model.--On Mon, Nov 4, 2013 at 1:57 AM, 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!
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/CAHSNPWtW89SBNRnCh_EO6Uj1hTPhixsxSRwq%3DhHmuGzdTJfWAg%40mail.gmail.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/CAEGxL4mu-%3DNkLMFz96m5tVr2%3DAggDh470%3DnRp7dKqWEgUvTQgQ%40mail.gmail.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/CAHSNPWu3sGB%3Dexcqy_fSOpOKd%2B-WBeeoU3mm_v9b1j7iuGhMsg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home