What I want is that, each user will have a set of `profile pictures`,
`background images` and other set of `photos uploaded`. These images will
be kept separately in the templates. And if the user wants, he can easily
use (copy) the other set of photos uploaded or images from the background
image set, as the profile picture, and that image will be added to `profile
picture set`. Or if he wants, he can use an image from `profile picture
set` or from the other `uploaded photos` as the `background image` and
similarly that image used from other class will be copied to `background
image set`.


On Tue, Nov 5, 2013 at 4:03 AM, Aamu Padi <aamup...@gmail.com> wrote:

> This is my models.py:
>
>     class Image(models.Model):
>         user = models.ForeignKey(User)
>         caption = models.CharField(max_length=300)
>         image = models.ImageField(upload_to=get_upload_file_name)
>         pub_date = models.DateTimeField(default=datetime.now)
>
>         class Meta:
>             ordering = ['-pub_date']
>             verbose_name_plural = ('Images')
>
>         def __unicode__(self):
>             return "%s - %s" % (self.caption, self.user.username)
>
>
>     class ProfilePic(Image):
>         pass
>
>
>
>     class BackgroundPic(Image):
>         pass
>
>
>     class Album(models.Model):
>         name = models.CharField(max_length=150)
>
>         def __unicode__(self):
>             return self.name
>
>
>     class Photo(Image):
>         album = models.ForeignKey(Album, default=3)
>
> And this is another:
>
>     class UserProfile(models.Model):
>         user = models.OneToOneField(User)
>         permanent_address = models.TextField()
>         temporary_address = models.TextField()
>         profile_pic = models.ForeignKey(ProfilePic)
>         background_pic = models.ForeignKey(BackgroundPic)
>
>         def __unicode__(self):
>             return self.user.username
>
> I can access the Parent class with its User object.
>
>     >>>m = User.objects.get(username='mika')
>     >>>m.image_set.all()
>     >>>[<Image: mika_photo - mika>, <Image: mika_pro - mika>, <Image:
> mika_bf - mika>]
>
>
> But I can't access its child class with the User. I tried:
>
>     >>>m.Image.profilepic_set.all()
> and
>
>     >>>m.image_set.profilpic.all()
>
> and this
>
>     >>>m.profilepic_set.all()
>     AttributeError:'User' object has no attribute 'profilepic_set'
>
> But all gave me errors!  How do I access the child classes, so that I can
> add images from one class to another. Like copy one image from Photo to
> ProfilePic, or from ProfilePic to BackgroundPic and so. Or simply, how to
> add images for particular User in specific classes?
>
> Please guide me to achieve the above mentioned. Will be much appreciated.
> 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+unsubscr...@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/CAHSNPWuofMKV1PLdcPJ8FTk4BsHiBAC2VrOQ4xZw4MNUd1U4uw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to