MikeKJ
unread,Nov 29, 2012, 9:06:53 AM11/29/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
I dont get the hot_topic_set.all from the newsletter instance x and I really don't see why can anyone else please?
model:
class NewsLetter(models.Model):
title = models.CharField(max_length=200)
text = models.TextField(null=True, blank=True)
document = models.FileField(upload_to="newsletters/", null=True, blank=True)
priority = models.IntegerField(default=50)
def __unicode__(self):
return self.title
def get_absolute_url(self):
return "/newsletters/"
class Meta:
ordering = ('priority',)
class Hot_Topic(models.Model):
newsletter = models.ForeignKey(NewsLetter, related_name="letter_set")
topic = models.CharField(max_length=100)
priority = models.IntegerField(default=50)
class Meta:
verbose_name_plural = "Hot Topics"
ordering = ('priority',)
view
def index(request):
list = NewsLetter.objects,all()
return render_to_response('newsletter/index.html', {''list': list,}, context_instance=RequestContext(request))
template:
{% for x in list %}
{% if x.text %}
.........
{% else %}
{% for t in x.hot_topic_set.all %}
{{ t.topic }}
{% endfor %}
{% endif %}
{% endfor %}
I dont get the hot_topic_set.all from the newsletter instance x and I really don't see why can anyone else please?