On Mon, 2012-06-04 at 05:23 -0700, by-neron wrote:
> i have a project called mysite and project has an application called
> blog. Project file has template/ directory which includes html files
> of site.Additionally, blog application has a model like that
> 
> class Post(models.Model):
>     title = models.CharField(max_length=100)
>     body = models.TextField()
>     created = models.DateTimeField()
>     tags = TaggableManager()
> 
> 
>     def __unicode__(self):
>      return self.title
> in this app i have also view.py
> 
> from django.template import Context, loader
> from blog.models import Post
> from django.http import HttpResponse
> 
> def index(request):
>     latestPosts = Post.objects.all().order_by('-created')[:5]
>     t = loader.get_template('/mysite/templates/index.html')
>     c = Context({
>         'latestPosts': latestPosts,
>     })
>     return HttpResponse(t.render(c))
> however,
> 
> in mysite/template/index.html
> 
>  {% for post in latestPosts %}
>      {{ post.id }}
>     {% endfor %}
> prints nothing because it could not send data here. How can i send
> it ?
> 
> 

looks ok - what about your urlconf?
-- 
regards
Kenneth Gonsalves

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to