> From: Mike Albert > Subject: Newbie Help with Models and Views > > I have a couple test rows of data in my database. From the > interactive shell (manage.py shell), I can return data correctly with > Post.objects.filter(id=1).
You'll notice that that data is coming back as ['row 1']. It's in a list. > When I attempt to return the same > data with my view, it does not appear to work. Here is the view: > > from django.http import HttpResponse > from board.models import Post > > def current_board(request): > posts = Post.objects.filter(id=1) > html = "<html><body> %s</body><html>" % posts > return HttpResponse(html) > > > The above simply prints "[ ]" Any thoughts? I'm a django > newbie with no programming experience, so I'm sure it's > something basic. Thanks in advance for the help! .filter returns a list of the items that match the query. So you're trying to stringify a list. That's where the '[' and ']' are coming from. I don't know why you're not seeing any of the items in that list, because my testing: >>> foo = [1,2,3] >>> print 'x%sx' % foo x[1, 2, 3]x shows that stringifying a list should print the list as you'd expect. But this may lead you to a solution. Hope this helps, -- Paul Wayper SYSTEMS ENGINEER TransACT Telephone: 02 6229 8026 Mobile: 0422 392 081 PO Box 1006, Civic Square ACT 2608 http://www.transact.com.au Please avoid printing this email! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---