El 03/03/10 10:45, zubin71 escribió: > >From a method defined in a view i need to get the source of an html > file in the templates directory. This is how i tried it out. An error > occurs at the line, > > f = open(os.path.join(os.getcwd(), '../templates/test.html'), 'r') ; > > However, this causes an error, "File or directory not found". > > What do i do? Please help. >
Obviously the path returned by os.path.join(os.getcwd(), '../templates/test.html') is wrong, but if the file is in the templates directory you can fetch its contents using Django's template module render_to_string function: from django.template.loader import render_to_string contents = render_to_string('test.html', {}) -- Gonzalo Delgado <gonzalo...@gmail.com> -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.