Thursday, August 29, 2013

Re: need a help in ListView 1) how to debug the rendered request and response

On Wed, Aug 28, 2013 at 7:08 PM, bab mis <babmis307@gmail.com> wrote:
> Here is my code
>
> models.py
> =======
> class member(models.Model):
> first_name = models.CharField(max_length=30)
> last_name = models.CharField(max_length=30)
> dob = models.DateField()
>
> def get_fields(self):
> return(self.__dict__.keys()[0:len(self.__dict__.keys())-2])
>
>
> views.py
> ======
> class ListContactView(ListView):
>
> template_name = 'member_list.html'
> model=member
> member_list = member.objects.all()
> memberobj = member()
> def listcontacttab(self):
> import tablib
> head=memberobj.get_fields()
> d=tablib.Dataset()
> d.headers=head
> for obj in member_list:
> values=[]
> for mem in head:
> values.append(obj.__dict__[mem].__str__())
> d.append(values)
>
>
> return render_to_response(template_name,{'member_list':d})

Note, the template variable is called 'member_list'

>
>
>
> template:
>
> <ul>
> {{ d.html }}
> </ul>

So 'd' will be undefined.


Cheers

Tom

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment