On Thu, Nov 29, 2012 at 8:06 AM, MikeKJ <mike.jones@paston.co.uk> wrote:
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?
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/LWo5COXB5-wJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment