Hey,

I am trying to build an interface using django. This way i am learning 
django as well.

So i have completed web-poll tutorial and i tried something on my own.

My problem, 

I have a file with following content.

*# Stats*

*total_connections_received:2*

*total_commands_processed:1*

*instantaneous_ops_per_sec:0*

*rejected_connections:0*

*expired_keys:0*

*evicted_keys:0*

*keyspace_hits:0*

*keyspace_misses:0*

*pubsub_channels:0*

*pubsub_patterns:0*

*latest_fork_usec:0*



*# Keyspacedb0:keys=6,expires=0*



Now, i want to display the above content in a table from on the web 
interface.

Following is my directory structre where mysite is the root app and polls 
is the secondary app.

ravi@ravi-ThinkPad-X230:~/python/mysite$ tree
.
├── manage.py
├── mysite
│   ├── __init__.py
│   ├── __init__.pyc
│   ├── settings.py
│   ├── settings.pyc
│   ├── urls.py
│   ├── urls.pyc
│   ├── wsgi.py
│   └── wsgi.pyc
└── polls
    ├── admin.py
    ├── admin.pyc
    ├── __init__.py
    ├── __init__.pyc
    ├── models.py
    ├── models.pyc
    ├── static
    │   └── polls
    │       ├── images
    │       │   └── images.jpg
    │       └── style.css
    ├── templates
    │   └── polls
    │       ├── detail.html
    │       ├── index.html
    │       ├── results.html
    │       └── table.html
    ├── test.py
    ├── test.pyc
    ├── tests.py
    ├── tests.pyc
    ├── urls.py
    ├── urls.pyc
    ├── views.py
    └── views.pyc

7 directories, 29 files

following is my polls/templates/polls/table.html

*{% if line %}*
*    <table style="width:300px">*
*    {% for x in line  %}*
*        <tr>*
*            <td>{{ x }}</td>*
*        </tr>*
*    {% endfor %}*
*    </table>*
*{% else %}*
*    <p>No polls are available.</p>*
*{% endif %}*

following is my polls/views.py

*from django.shortcuts import get_object_or_404, render*
*from django.http import Http404, HttpResponse, HttpResponseRedirect*
*from polls.models import Choice, Poll*
*from django.core.urlresolvers import reverse*
*from django.template import RequestContext, loader*
*from django.views import generic*
*from django.core.files import File*

*def table(request):*
*        with open('/home/ravi/python/temp.txt', 'r') as f:*
*                for line in f:*
*                        context = {'line': line}*
*                return render(request, 'polls/table.html', context)*


when it the url, 

http://127.0.0.1:8000/polls/table

I get the following output,

d
b
0
:
k
e
y
s
=
6
,
e
x
p
i
r
e
s
=
0

but i want the output as each line of the file as a row in the table. 

Any help. 

-- 
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+unsubscr...@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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/628bc9c0-b3fd-4724-ab6a-d951ab31980f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to