So when I go to build the entries for my drop down list then I would iterate over the query results like you suggested and at that point where I iterate over the results then I can also set the different select option attributes (html option tag attributes - value and visible-choice) to the various values contained in each object returned in the queryset. Right?
On Feb 10, 10:50 am, Ian Clelland <clell...@gmail.com> wrote: > all() is a method on a Manager instance, that returns a QuerySet > containing every row in the table, without filtering. It is used > because you can't iterate over a Manager, only over a QuerySet. > > As an example, if MyModel is a model, then MyModel.objects is a > Manager. If you tried to do this in python: > > for obj in MyModel.objects: > # something > > You would see an exception raised. In this case, you need to iterate > over MyModel.objects.all(). > > A RawQuerySet, though, is already a QuerySet. You can just iterate > over it, and it will just return every row that your SQL produces. > (Actually, that's pretty much all you can do with it, there's no way > for the ORM to add any other filtering or ordering to your custom SQL) > > So, instead of trying to call all() on the QuerySet, just iterate over > it -- rather than > > {% for obj in my_raw_query_set.all %} > > just do > > {% for obj in my_raw_query_set %} > > > > > > On Thu, Feb 10, 2011 at 7:28 AM, hank23 <hversem...@stchas.edu> wrote: > > I'm trying to use raw SQL to retrieve the information that I want to > > display in a dropdown list. Here's the error that I'm getting: > > > TemplateSyntaxError at /polls/updatepath/ > > Caught AttributeError while rendering: 'RawQuerySet' object has no > > attribute 'all' > > > I'm not sure what this is trying to tell me. I used the same SQL > > syntax that is shown in the documentation at: > > >http://docs.djangoproject.com/en/dev/topics/db/sql/ > > > Can somebody explain this to me? thanks. > > > -- > > 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 > > athttp://groups.google.com/group/django-users?hl=en. > > -- > Regards, > Ian Clelland > <clell...@gmail.com>- Hide quoted text - > > - Show quoted text - -- 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.