Hi: I have several Django applications running and I am trying to tidu up some code.
I am trying to make a generic way of viewing a database table on a web page using a YUI control. I am using the Django template to attempt to create the required javascript for the YUI controls. I become a bit stuck, in that I can't seem to iterate over the fields in a record in a Django template. For example I have a project table as follows: class projects(models.Model): projectName = models.CharField('Project Name', max_length=50, null=False) projectDescription = models.TextField('Project Description', null=True) projectManager = models.CharField('Project Manager', max_length=50, null=True) projectOwner = models.CharField('Project Owner', max_length=50, null=True) projectDate = models.DateField('Project Date', null=False) projectHidden = models.BooleanField('Project Hidden', null=True) Then there is a Django view that is used to get the data to render, in that I get a list of all the projects: projList = projects.objects.all() projList is then passed into the function that renders the page. I can go through each record in the projList using: {% for projectItem in projList %} : : {% endfor %} However I can't seem to go through each field in an individual record for example this doesn't work: {% for projectItem in projList %} {% for fieldval in projectItem.fields %} {{fieldval.name }} -:- {{ fiieldVal.str }} {% endfor %} {% endfor %} This doesn't cause an error but it doesn't produce any output. I can access the fields using the field names {% for projectItem in projList %} {{ projList.projectName }} : {% endfor %} This produces an output but this gets away from the point of making a generic function.. Is this possible? Is this because the fields are not bound to a form's fields? Any help or advice would be greatly apprecriated! Thanks. Paul Lundberg --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---