I agree. It's very easy to use the templates to do just that. Once you have
them processed and saved as a variable (which would be a string) then you
can do anything with them that Python is capable of. For example, you could
use them to generate emails, save text files, etc...

As far as calling C++ goes -- you could use subprocess if the C++ is an
actual executable program and not just a library you're trying to call or
some source you've written yourself. In the latter two cases, ignore Django
and think about this in terms of "Accessing C++ from Python". Googling that
will lead to several answers. The easiest way I've found is to externalize
C functions that call C++ code and use Python CTypes (included in the
standard library) to call those external C functions.

Good luck!

On Tue, Jun 19, 2012 at 9:10 AM, Melvyn Sopacua <m.r.sopa...@gmail.com>wrote:

> On 19-6-2012 14:37, Blaxton wrote:
> > My understanding from template system was:
> > Django template system is to create html files on fly while returning
> > the resulting html to user's browser!
>
> Nope, that's just the default use. The template system can be used for
> anything to return "text" based on a "context".
>
> > How can I save the created files by template system on file system ?
>
> You'd do that in your view, similar to how mail is sent in this example:
> <
> https://docs.djangoproject.com/en/1.4/topics/forms/#processing-the-data-from-a-form
> >
>
> Except that you use:
> <
> https://docs.djangoproject.com/en/1.4/ref/templates/api/#rendering-a-context
> >
>
> So your process is:
> - show editing form to user using a HTML template that gets sent to browser
> - validate the form and clean the data
> - render the template that generates your file based on the form data
> - write the file using standard python file methods
> - redirect the user
>
> It's similar to this:
> https://docs.djangoproject.com/en/1.4/howto/outputting-csv/
>
> except don't call response.write() but write to a file.
> --
> Melvyn Sopacua
>
> --
> 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.
>
>

-- 
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.

Reply via email to