Why do you want to do this! It looks complicated and badly formed. -V
On Mon, Mar 3, 2014 at 12:11 AM, Kakar Nyori <nyorika...@gmail.com> wrote: > Hello, > This may be long, but I really need your help. I have a class *Asset*, > which is the *base class* of another *classes *(like *Photo, Question, > Video etc.*) Basically its a *Multiple Table Inheritance*. I need this to > get all the post or all the *objects* of the user. And it does what I > want. But I saw that, many were against *Multiple Table Inheritance, *or > if not they discouraged MTI. So, I really need to know that, *how much > will it matter*? Or is there any other way to achieve it. To get all the > objects of a *User*? Please help me decide what to do. If I am not clear, > please ask me. I will really appreciate if anyone would guide me through > this. > > Thank you. > > *This are my models:* > > > class Asset(models.Model): > user = models.ForeignKey(User, related_name = "user_objects") > likes = models.ManyToManyField(User, through="Like", > related_name="Liked_user") > comments = models.ManyToManyField(User, through="Comment", > related_name="Commented_user") > timestamp = models.DateTimeField(auto_now = True, auto_now_add= False) > updated = models.DateTimeField(auto_now = False, auto_now_add = True) > > class Meta: > ordering = ['-timestamp'] > > def __unicode__(self): > return self.__class__.__name__ > > class Like(models.Model): > asset = models.ForeignKey(Asset) > liked_by = models.ForeignKey(User) > liked_time = models.DateTimeField(auto_now = True, auto_now_add = False) > > def __unicode__(self): > return "%s likes %s" % (self.liked_by, self.asset) > > class Comment(models.Model): > asset = models.ForeignKey(Asset) > comment_by = models.ForeignKey(User) > liked_time = models.DateTimeField(auto_now = True, auto_now_add = False) > > def __unicode__(self): > return "%s likes %s" % (self.comment_by, self.asset) > > def get_upload_file_name(instance, filename): > return "uploaded_files/%s_%s" %(str(time()).replace('.','_'), filename) > > class Album(Asset): > title = models.CharField(max_length=200) > description = models.TextField() > > def __unicode__(self): > return self.__class__.__name__ > > > class Picture(Asset): > description = models.TextField() > image = models.ImageField(upload_to=get_upload_file_name) > album = models.ForeignKey(Album, null=True, blank=True, default = None) > > def __unicode__(self): > return self.__class__.__name__ > > class BackgroundImage(Picture): > pass > > class ProfilePicture(Picture): > pass > > class Tag(models.Model): > title = models.CharField(max_length=40) > description = models.TextField() > > def __unicode__(self): > return self.title > > class Question(Asset): > title = models.CharField(max_length=200) > description = models.TextField() > tags = models.ManyToManyField(Tag) > > def __unicode__(self): > return self.title > > class Answer(Asset): > description = models.TextField() > question = models.ForeignKey(Question) > > def __unicode__(self): > return self.description > > -- > 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/871d20b8-17a3-4ed4-bb8e-3c0befb5121f%40googlegroups.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+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/CAN7tdFT8LLLLkrBHrLjvSy7Hn35mAk0%2BBDXvOgcpXjNX_wMOZg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.