I am having a hard time to understand ContentType. I am learning from a tutorial, this is the link . I have synced the database, and its working in the admin. But when I try to load the ContentType objects in the template, I get nothing. When I see the page source, the get_rendered_method is not loading the rendered template in the homepage.html.
*These are my models:* class Photo(models.Model): user = models.ForeignKey(User) description = models.TextField() image = models.ImageField(upload_to=get_upload_file_name) photo_upload = models.DateTimeField(auto_now=True, auto_now_add=False) is_public = models.BooleanField(default=True) class Meta: verbose_name = 'Photo' verbose_name_plural = 'Photos' ordering = ['-photo_upload'] class Status(models.Model): user = models.ForeignKey(User) state = models.CharField(max_length=200) status_upload = models.DateTimeField(auto_now=True, auto_now_add=False) is_public = models.BooleanField(default=True) class StreamItem(models.Model): content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() pub_date = models.DateTimeField() content_object = generic.GenericForeignKey('content_type','object_id') # The get_rendered_html method simply passes the retrieved object to a template with that object's name def get_rendered_html(self): template_name = 'stream_item_%s.html' % (self.content_type.name) return render(request, template_name, {'object':self.content_object}) *These are the template for content_type.name <http://content_type.name>:* *stream_item_Photo.html:* <div class="si"> <img src="{{ object.image }}"> <p>{{ object.pub_date|date:"F jS Y, P" }}</p> <p>{{ object.user }}</p> </div> *stream_item_Status.html:* <div class="si"> <p>{{ object.state }}</p> <p>{{ object.time|date:"F jS Y, P" }}</p> <p>User: {{ object.user }}</p> </div> Where am I doing the mistake? How do I load different content_type objects in the template? I would really appreciate if you could help me solve this. 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/CA%2B4-nGpg3-btzb5r9en9MVipb9zY_O2_B989%3DxE0sm3VgT8Lyg%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.