It's clear now that __str__(self) or __unicode__
return a usable string to the view.

But this does not on the surface appear to be a
workable instance of the model itself,
that would return fields that I can work with in the template...and/or
i haven't figured how to get a handle on it.

ie...
to list titles by Stevenson and checkbox titles to be borrowed.
...which in the browser I'd hope would present something like
_______________________________________________________
...
[ ] Stevenson Collected Works
[ ] Stevenson Treasure Island
[ ] Stevenson Wild West Stories
...
[Submit]

here is the code i'm trying...
______________________________________________________
# models.py
class Titles(models.Model):

    author = models.CharField(max_length=100)

    title  = models.CharField(max_length=254)

    select = models.BooleanField()

    def __unicode__(self):
        return u'%s = %s' % (self.author, self.title)
________________________________________________________
# views.py
def checkout_book_view(request)
    from books.models import Titles

    titles_list =Titles.objects.filter(author="Stevenson")

    template_Name='checkoutbook.htm'
    template_Context = Context( { 'titles_list': titles_list })

   return render_to_response(template_Name,template_Context)
________________________________________________________
# then in template checkoutbook.html list as
{% for titles_list in titles_list %}
{{ title.select }}
{{ title.author }}
{{ title.title  }}
{% endfor %}

with unicode though all i'm able to get is the single string defined
by def ___unicode___ and no check box. i'm suprised
that the query set or list is not able to store more fields.




--~--~---------~--~----~------------~-------~--~----~
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