Skip to content

Instantly share code, notes, and snippets.

@herberthamaral
Created November 22, 2011 20:36
Show Gist options
  • Save herberthamaral/1386854 to your computer and use it in GitHub Desktop.
Save herberthamaral/1386854 to your computer and use it in GitHub Desktop.
from django.http import HttpResponse
from models import Post
def posts(request):
posts = Post.objects.all()
texto = "<h1>Lista de posts:</h1>"
texto += "<ul>"
for post in posts:
item = "<li><a href='/blog/post/"+str(post.id)+"'>"+post.title+"</a></li>"
texto += item
texto += "</ul>"
return HttpResponse(texto)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment