Friday, April 15, 2011

Re: Passing variables to the template... I've having logic problems

You can try something like:

def my_view(request):
.... <code here> ...

context = []
for offset in offsets:
before = ' '.join(tokens[offset-5:offset])
word = tokens[offset]
after = ' '.join(tokens[offset+1:offset+5])
context.append(before, word, after)

... <more code here> ...

return render_to_response("template.html", {'context': context})

Now your data will be available inside the 'context' variable and you
can access the 'context' variable in your template like you want. I
hope that helps.

Pedro

--
http://pedrokroger.net

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate