Re: Load Template without rendering/parsing
Well, that preaty much closes the case Bill.. already created a function that loads the file independently, and returns a HttpResponse with its contents... But thanks a lot for everyones help! Em seg, 16 de mar de 2015 às 11:44, Bill Freemanescreveu: > But that's what the template loader does. It loads *DJANGO* templates. > If it does the loading, the template will receive Django processing. > > I see two choices: > > 1. Quote everything in the template that looks like a Django template > special syntax so that the rendering process instead just renders it as > what you wanted orriginally. > > 2. Load the file yourself. Yes, you have to know the path or search > suitable sub-directories of installed apps yourself. But those directories > probably shouldn't be called "templates", because those are for Django > templates. Perhaps "angular_templates"? > > On Mon, Mar 16, 2015 at 10:24 AM, Guilherme Leal > wrote: > >> Just to clarify the things a little bit more to Avraham.. i DO want the >> request to pass through django >> >> what i dont want is that django treat this particular html as a template. >> >> Em seg, 16 de mar de 2015 às 11:15, Guilherme Leal >> escreveu: >> >>> Can you give me an exemple? >>> >>> Em seg, 16 de mar de 2015 às 11:05, Avraham Serour >>> escreveu: >>> >>> if you don't want django to render your angularjs template file then don't. You could treat it as a static file, same way as a .png, the request woudn't even get to django you can not use render to return on the view, instead return the file without loading it in the template renderer On Mon, Mar 16, 2015 at 3:55 PM, Guilherme Leal wrote: > and the {% ssi %} was the winner :) > > the only thing that i didnt liked is that i have to strictly type the > file path. But that would happend either way, working with the file > directly or not. > > anyway, worked with the {% ssi %}. > > Thanks A LOT! > > Em seg, 16 de mar de 2015 às 10:32, François Schiettecatte < > fschietteca...@gmail.com> escreveu: > > I am not sure what you mean. >> >> I have this is urls.py >> >> # Root view, goes to 'app.home.views.page' >> (r'^$', 'app.home.views.page'), >> >> and the code below in page() in views.py, django routes ‘/‘ to that >> view and it renders the home page. >> >> Or you could use {% ssi %} to include the angular stuff. >> >> François >> >> >> > On Mar 16, 2015, at 9:01 AM, Guilherme Leal >> wrote: >> > >> > This solution crossed my mind, and the only down side that i see on >> it, is that i cant use the "template.loader" logic for finding the right >> template. >> > >> > Em seg, 16 de mar de 2015 às 09:59, François Schiettecatte < >> fschietteca...@gmail.com> escreveu: >> > You can just read the file content and return it with an >> HttpResponse(), like this: >> > >> > >> > # File handle >> > fileHandle = None >> > >> > # Open the file, return a 404 if failed >> > try: >> > fileHandle = open(filePath, 'r') >> > except IOError: >> > raise Http404() >> > >> ># Return the file >> > return HttpResponse(content=fileHandle.read(), >> content_type=’text/html') >> > >> > François >> > >> > >> > > On Mar 16, 2015, at 8:49 AM, Guilherme Leal >> wrote: >> > > >> > > Hello! >> > > >> > > Anyone knows a way to load a template file WITHOUT >> parsing/rendering it? >> > > >> > > To ilustrate a bit more: >> > > >> > > I have a django app serving a restfull api, and everithing is >> just fine with it. The front end that consumes this api, is an Angular.js >> single page app. To centralize the routing logic, what i want to do is to >> let django to serve the "index.html" of this app. The only problem is, >> when >> i load the html of the front end (through "django.template.loader.get_ >> template"), the template engine tries to parse it, and throws an >> exception because this "template" has the angularjs template tags on it. >> > > >> > > What i need is: >> > > - Load the template without parsing/rendering it >> > > OR >> > > - Serve this html document as static in production (the static >> serving view only works when debug is activated) >> > > >> > > Thanx in advance! >> > > >> > > -- >> > > 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
Re: Load Template without rendering/parsing
return HttpResponse(content, content_type='text/html') On Mon, Mar 16, 2015 at 4:43 PM, Bill Freemanwrote: > But that's what the template loader does. It loads *DJANGO* templates. > If it does the loading, the template will receive Django processing. > > I see two choices: > > 1. Quote everything in the template that looks like a Django template > special syntax so that the rendering process instead just renders it as > what you wanted orriginally. > > 2. Load the file yourself. Yes, you have to know the path or search > suitable sub-directories of installed apps yourself. But those directories > probably shouldn't be called "templates", because those are for Django > templates. Perhaps "angular_templates"? > > On Mon, Mar 16, 2015 at 10:24 AM, Guilherme Leal > wrote: > >> Just to clarify the things a little bit more to Avraham.. i DO want the >> request to pass through django >> >> what i dont want is that django treat this particular html as a template. >> >> Em seg, 16 de mar de 2015 às 11:15, Guilherme Leal >> escreveu: >> >>> Can you give me an exemple? >>> >>> Em seg, 16 de mar de 2015 às 11:05, Avraham Serour >>> escreveu: >>> >>> if you don't want django to render your angularjs template file then don't. You could treat it as a static file, same way as a .png, the request woudn't even get to django you can not use render to return on the view, instead return the file without loading it in the template renderer On Mon, Mar 16, 2015 at 3:55 PM, Guilherme Leal wrote: > and the {% ssi %} was the winner :) > > the only thing that i didnt liked is that i have to strictly type the > file path. But that would happend either way, working with the file > directly or not. > > anyway, worked with the {% ssi %}. > > Thanks A LOT! > > Em seg, 16 de mar de 2015 às 10:32, François Schiettecatte < > fschietteca...@gmail.com> escreveu: > > I am not sure what you mean. >> >> I have this is urls.py >> >> # Root view, goes to 'app.home.views.page' >> (r'^$', 'app.home.views.page'), >> >> and the code below in page() in views.py, django routes ‘/‘ to that >> view and it renders the home page. >> >> Or you could use {% ssi %} to include the angular stuff. >> >> François >> >> >> > On Mar 16, 2015, at 9:01 AM, Guilherme Leal >> wrote: >> > >> > This solution crossed my mind, and the only down side that i see on >> it, is that i cant use the "template.loader" logic for finding the right >> template. >> > >> > Em seg, 16 de mar de 2015 às 09:59, François Schiettecatte < >> fschietteca...@gmail.com> escreveu: >> > You can just read the file content and return it with an >> HttpResponse(), like this: >> > >> > >> > # File handle >> > fileHandle = None >> > >> > # Open the file, return a 404 if failed >> > try: >> > fileHandle = open(filePath, 'r') >> > except IOError: >> > raise Http404() >> > >> ># Return the file >> > return HttpResponse(content=fileHandle.read(), >> content_type=’text/html') >> > >> > François >> > >> > >> > > On Mar 16, 2015, at 8:49 AM, Guilherme Leal >> wrote: >> > > >> > > Hello! >> > > >> > > Anyone knows a way to load a template file WITHOUT >> parsing/rendering it? >> > > >> > > To ilustrate a bit more: >> > > >> > > I have a django app serving a restfull api, and everithing is >> just fine with it. The front end that consumes this api, is an Angular.js >> single page app. To centralize the routing logic, what i want to do is to >> let django to serve the "index.html" of this app. The only problem is, >> when >> i load the html of the front end (through "django.template.loader.get_ >> template"), the template engine tries to parse it, and throws an >> exception because this "template" has the angularjs template tags on it. >> > > >> > > What i need is: >> > > - Load the template without parsing/rendering it >> > > OR >> > > - Serve this html document as static in production (the static >> serving view only works when debug is activated) >> > > >> > > Thanx in advance! >> > > >> > > -- >> > > 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.
Re: Load Template without rendering/parsing
But that's what the template loader does. It loads *DJANGO* templates. If it does the loading, the template will receive Django processing. I see two choices: 1. Quote everything in the template that looks like a Django template special syntax so that the rendering process instead just renders it as what you wanted orriginally. 2. Load the file yourself. Yes, you have to know the path or search suitable sub-directories of installed apps yourself. But those directories probably shouldn't be called "templates", because those are for Django templates. Perhaps "angular_templates"? On Mon, Mar 16, 2015 at 10:24 AM, Guilherme Lealwrote: > Just to clarify the things a little bit more to Avraham.. i DO want the > request to pass through django > > what i dont want is that django treat this particular html as a template. > > Em seg, 16 de mar de 2015 às 11:15, Guilherme Leal > escreveu: > >> Can you give me an exemple? >> >> Em seg, 16 de mar de 2015 às 11:05, Avraham Serour >> escreveu: >> >> if you don't want django to render your angularjs template file then >>> don't. >>> >>> You could treat it as a static file, same way as a .png, the request >>> woudn't even get to django >>> >>> you can not use render to return on the view, instead return the file >>> without loading it in the template renderer >>> >>> On Mon, Mar 16, 2015 at 3:55 PM, Guilherme Leal >>> wrote: >>> and the {% ssi %} was the winner :) the only thing that i didnt liked is that i have to strictly type the file path. But that would happend either way, working with the file directly or not. anyway, worked with the {% ssi %}. Thanks A LOT! Em seg, 16 de mar de 2015 às 10:32, François Schiettecatte < fschietteca...@gmail.com> escreveu: I am not sure what you mean. > > I have this is urls.py > > # Root view, goes to 'app.home.views.page' > (r'^$', 'app.home.views.page'), > > and the code below in page() in views.py, django routes ‘/‘ to that > view and it renders the home page. > > Or you could use {% ssi %} to include the angular stuff. > > François > > > > On Mar 16, 2015, at 9:01 AM, Guilherme Leal > wrote: > > > > This solution crossed my mind, and the only down side that i see on > it, is that i cant use the "template.loader" logic for finding the right > template. > > > > Em seg, 16 de mar de 2015 às 09:59, François Schiettecatte < > fschietteca...@gmail.com> escreveu: > > You can just read the file content and return it with an > HttpResponse(), like this: > > > > > > # File handle > > fileHandle = None > > > > # Open the file, return a 404 if failed > > try: > > fileHandle = open(filePath, 'r') > > except IOError: > > raise Http404() > > > ># Return the file > > return HttpResponse(content=fileHandle.read(), > content_type=’text/html') > > > > François > > > > > > > On Mar 16, 2015, at 8:49 AM, Guilherme Leal > wrote: > > > > > > Hello! > > > > > > Anyone knows a way to load a template file WITHOUT > parsing/rendering it? > > > > > > To ilustrate a bit more: > > > > > > I have a django app serving a restfull api, and everithing is just > fine with it. The front end that consumes this api, is an Angular.js > single > page app. To centralize the routing logic, what i want to do is to let > django to serve the "index.html" of this app. The only problem is, when i > load the html of the front end (through > "django.template.loader.get_template"), > the template engine tries to parse it, and throws an exception because > this > "template" has the angularjs template tags on it. > > > > > > What i need is: > > > - Load the template without parsing/rendering it > > > OR > > > - Serve this html document as static in production (the static > serving view only works when debug is activated) > > > > > > Thanx in advance! > > > > > > -- > > > 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/CAOs3Lp43aDqX > DSfNNcH10gUvAZB-3UazGEL45bW59t-6Hyay9Q%40mail.gmail.com. > > > For more options, visit https://groups.google.com/d/optout. > > >
Re: Load Template without rendering/parsing
Just to clarify the things a little bit more to Avraham.. i DO want the request to pass through django what i dont want is that django treat this particular html as a template. Em seg, 16 de mar de 2015 às 11:15, Guilherme Lealescreveu: > Can you give me an exemple? > > Em seg, 16 de mar de 2015 às 11:05, Avraham Serour > escreveu: > > if you don't want django to render your angularjs template file then don't. >> >> You could treat it as a static file, same way as a .png, the request >> woudn't even get to django >> >> you can not use render to return on the view, instead return the file >> without loading it in the template renderer >> >> On Mon, Mar 16, 2015 at 3:55 PM, Guilherme Leal >> wrote: >> >>> and the {% ssi %} was the winner :) >>> >>> the only thing that i didnt liked is that i have to strictly type the >>> file path. But that would happend either way, working with the file >>> directly or not. >>> >>> anyway, worked with the {% ssi %}. >>> >>> Thanks A LOT! >>> >>> Em seg, 16 de mar de 2015 às 10:32, François Schiettecatte < >>> fschietteca...@gmail.com> escreveu: >>> >>> I am not sure what you mean. I have this is urls.py # Root view, goes to 'app.home.views.page' (r'^$', 'app.home.views.page'), and the code below in page() in views.py, django routes ‘/‘ to that view and it renders the home page. Or you could use {% ssi %} to include the angular stuff. François > On Mar 16, 2015, at 9:01 AM, Guilherme Leal wrote: > > This solution crossed my mind, and the only down side that i see on it, is that i cant use the "template.loader" logic for finding the right template. > > Em seg, 16 de mar de 2015 às 09:59, François Schiettecatte < fschietteca...@gmail.com> escreveu: > You can just read the file content and return it with an HttpResponse(), like this: > > > # File handle > fileHandle = None > > # Open the file, return a 404 if failed > try: > fileHandle = open(filePath, 'r') > except IOError: > raise Http404() > ># Return the file > return HttpResponse(content=fileHandle.read(), content_type=’text/html') > > François > > > > On Mar 16, 2015, at 8:49 AM, Guilherme Leal wrote: > > > > Hello! > > > > Anyone knows a way to load a template file WITHOUT parsing/rendering it? > > > > To ilustrate a bit more: > > > > I have a django app serving a restfull api, and everithing is just fine with it. The front end that consumes this api, is an Angular.js single page app. To centralize the routing logic, what i want to do is to let django to serve the "index.html" of this app. The only problem is, when i load the html of the front end (through "django.template.loader.get_template"), the template engine tries to parse it, and throws an exception because this "template" has the angularjs template tags on it. > > > > What i need is: > > - Load the template without parsing/rendering it > > OR > > - Serve this html document as static in production (the static serving view only works when debug is activated) > > > > Thanx in advance! > > > > -- > > 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/CAOs3Lp43aDqX DSfNNcH10gUvAZB-3UazGEL45bW59t-6Hyay9Q%40mail.gmail.com. > > For more options, visit https://groups.google.com/d/optout. > > -- > 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/FFC3A2C1-51A0-4A2D-9D94-EEF0C511C5A6%40gmail.com. > For more options, visit https://groups.google.com/d/optout. > > -- > 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
Re: Load Template without rendering/parsing
Can you give me an exemple? Em seg, 16 de mar de 2015 às 11:05, Avraham Serourescreveu: > if you don't want django to render your angularjs template file then don't. > > You could treat it as a static file, same way as a .png, the request > woudn't even get to django > > you can not use render to return on the view, instead return the file > without loading it in the template renderer > > On Mon, Mar 16, 2015 at 3:55 PM, Guilherme Leal > wrote: > >> and the {% ssi %} was the winner :) >> >> the only thing that i didnt liked is that i have to strictly type the >> file path. But that would happend either way, working with the file >> directly or not. >> >> anyway, worked with the {% ssi %}. >> >> Thanks A LOT! >> >> Em seg, 16 de mar de 2015 às 10:32, François Schiettecatte < >> fschietteca...@gmail.com> escreveu: >> >> I am not sure what you mean. >>> >>> I have this is urls.py >>> >>> # Root view, goes to 'app.home.views.page' >>> (r'^$', 'app.home.views.page'), >>> >>> and the code below in page() in views.py, django routes ‘/‘ to that view >>> and it renders the home page. >>> >>> Or you could use {% ssi %} to include the angular stuff. >>> >>> François >>> >>> >>> > On Mar 16, 2015, at 9:01 AM, Guilherme Leal >>> wrote: >>> > >>> > This solution crossed my mind, and the only down side that i see on >>> it, is that i cant use the "template.loader" logic for finding the right >>> template. >>> > >>> > Em seg, 16 de mar de 2015 às 09:59, François Schiettecatte < >>> fschietteca...@gmail.com> escreveu: >>> > You can just read the file content and return it with an >>> HttpResponse(), like this: >>> > >>> > >>> > # File handle >>> > fileHandle = None >>> > >>> > # Open the file, return a 404 if failed >>> > try: >>> > fileHandle = open(filePath, 'r') >>> > except IOError: >>> > raise Http404() >>> > >>> ># Return the file >>> > return HttpResponse(content=fileHandle.read(), >>> content_type=’text/html') >>> > >>> > François >>> > >>> > >>> > > On Mar 16, 2015, at 8:49 AM, Guilherme Leal >>> wrote: >>> > > >>> > > Hello! >>> > > >>> > > Anyone knows a way to load a template file WITHOUT parsing/rendering >>> it? >>> > > >>> > > To ilustrate a bit more: >>> > > >>> > > I have a django app serving a restfull api, and everithing is just >>> fine with it. The front end that consumes this api, is an Angular.js single >>> page app. To centralize the routing logic, what i want to do is to let >>> django to serve the "index.html" of this app. The only problem is, when i >>> load the html of the front end (through >>> "django.template.loader.get_template"), >>> the template engine tries to parse it, and throws an exception because this >>> "template" has the angularjs template tags on it. >>> > > >>> > > What i need is: >>> > > - Load the template without parsing/rendering it >>> > > OR >>> > > - Serve this html document as static in production (the static >>> serving view only works when debug is activated) >>> > > >>> > > Thanx in advance! >>> > > >>> > > -- >>> > > 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/ >>> CAOs3Lp43aDqXDSfNNcH10gUvAZB-3UazGEL45bW59t-6Hyay9Q%40mail.gmail.com. >>> > > For more options, visit https://groups.google.com/d/optout. >>> > >>> > -- >>> > 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/FFC3A2C1-51A0-4A2D-9D94-EEF0C511C5A6%40gmail.com. >>> > For more options, visit https://groups.google.com/d/optout. >>> > >>> > -- >>> > 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/CAOs3Lp7DtTtDdmaYHp%3DnKAxD% >>> 2B-_SU7JtBqbyNMpPDRdqpnjTNw%40mail.gmail.com. >>> > For more
Re: Load Template without rendering/parsing
if you don't want django to render your angularjs template file then don't. You could treat it as a static file, same way as a .png, the request woudn't even get to django you can not use render to return on the view, instead return the file without loading it in the template renderer On Mon, Mar 16, 2015 at 3:55 PM, Guilherme Lealwrote: > and the {% ssi %} was the winner :) > > the only thing that i didnt liked is that i have to strictly type the file > path. But that would happend either way, working with the file directly or > not. > > anyway, worked with the {% ssi %}. > > Thanks A LOT! > > Em seg, 16 de mar de 2015 às 10:32, François Schiettecatte < > fschietteca...@gmail.com> escreveu: > > I am not sure what you mean. >> >> I have this is urls.py >> >> # Root view, goes to 'app.home.views.page' >> (r'^$', 'app.home.views.page'), >> >> and the code below in page() in views.py, django routes ‘/‘ to that view >> and it renders the home page. >> >> Or you could use {% ssi %} to include the angular stuff. >> >> François >> >> >> > On Mar 16, 2015, at 9:01 AM, Guilherme Leal >> wrote: >> > >> > This solution crossed my mind, and the only down side that i see on it, >> is that i cant use the "template.loader" logic for finding the right >> template. >> > >> > Em seg, 16 de mar de 2015 às 09:59, François Schiettecatte < >> fschietteca...@gmail.com> escreveu: >> > You can just read the file content and return it with an >> HttpResponse(), like this: >> > >> > >> > # File handle >> > fileHandle = None >> > >> > # Open the file, return a 404 if failed >> > try: >> > fileHandle = open(filePath, 'r') >> > except IOError: >> > raise Http404() >> > >> ># Return the file >> > return HttpResponse(content=fileHandle.read(), >> content_type=’text/html') >> > >> > François >> > >> > >> > > On Mar 16, 2015, at 8:49 AM, Guilherme Leal >> wrote: >> > > >> > > Hello! >> > > >> > > Anyone knows a way to load a template file WITHOUT parsing/rendering >> it? >> > > >> > > To ilustrate a bit more: >> > > >> > > I have a django app serving a restfull api, and everithing is just >> fine with it. The front end that consumes this api, is an Angular.js single >> page app. To centralize the routing logic, what i want to do is to let >> django to serve the "index.html" of this app. The only problem is, when i >> load the html of the front end (through >> "django.template.loader.get_template"), >> the template engine tries to parse it, and throws an exception because this >> "template" has the angularjs template tags on it. >> > > >> > > What i need is: >> > > - Load the template without parsing/rendering it >> > > OR >> > > - Serve this html document as static in production (the static >> serving view only works when debug is activated) >> > > >> > > Thanx in advance! >> > > >> > > -- >> > > 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/CAOs3Lp43aDqXDSfNNcH10gUvAZB- >> 3UazGEL45bW59t-6Hyay9Q%40mail.gmail.com. >> > > For more options, visit https://groups.google.com/d/optout. >> > >> > -- >> > 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/FFC3A2C1-51A0-4A2D-9D94-EEF0C511C5A6%40gmail.com. >> > For more options, visit https://groups.google.com/d/optout. >> > >> > -- >> > 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/CAOs3Lp7DtTtDdmaYHp%3DnKAxD% >> 2B-_SU7JtBqbyNMpPDRdqpnjTNw%40mail.gmail.com. >> > For more options, visit https://groups.google.com/d/optout. >> >> -- >> 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
Re: Load Template without rendering/parsing
and the {% ssi %} was the winner :) the only thing that i didnt liked is that i have to strictly type the file path. But that would happend either way, working with the file directly or not. anyway, worked with the {% ssi %}. Thanks A LOT! Em seg, 16 de mar de 2015 às 10:32, François Schiettecatte < fschietteca...@gmail.com> escreveu: > I am not sure what you mean. > > I have this is urls.py > > # Root view, goes to 'app.home.views.page' > (r'^$', 'app.home.views.page'), > > and the code below in page() in views.py, django routes ‘/‘ to that view > and it renders the home page. > > Or you could use {% ssi %} to include the angular stuff. > > François > > > > On Mar 16, 2015, at 9:01 AM, Guilherme Lealwrote: > > > > This solution crossed my mind, and the only down side that i see on it, > is that i cant use the "template.loader" logic for finding the right > template. > > > > Em seg, 16 de mar de 2015 às 09:59, François Schiettecatte < > fschietteca...@gmail.com> escreveu: > > You can just read the file content and return it with an HttpResponse(), > like this: > > > > > > # File handle > > fileHandle = None > > > > # Open the file, return a 404 if failed > > try: > > fileHandle = open(filePath, 'r') > > except IOError: > > raise Http404() > > > ># Return the file > > return HttpResponse(content=fileHandle.read(), > content_type=’text/html') > > > > François > > > > > > > On Mar 16, 2015, at 8:49 AM, Guilherme Leal > wrote: > > > > > > Hello! > > > > > > Anyone knows a way to load a template file WITHOUT parsing/rendering > it? > > > > > > To ilustrate a bit more: > > > > > > I have a django app serving a restfull api, and everithing is just > fine with it. The front end that consumes this api, is an Angular.js single > page app. To centralize the routing logic, what i want to do is to let > django to serve the "index.html" of this app. The only problem is, when i > load the html of the front end (through > "django.template.loader.get_template"), > the template engine tries to parse it, and throws an exception because this > "template" has the angularjs template tags on it. > > > > > > What i need is: > > > - Load the template without parsing/rendering it > > > OR > > > - Serve this html document as static in production (the static serving > view only works when debug is activated) > > > > > > Thanx in advance! > > > > > > -- > > > 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/CAOs3Lp43aDqXDSfNNcH10gUvAZB- > 3UazGEL45bW59t-6Hyay9Q%40mail.gmail.com. > > > For more options, visit https://groups.google.com/d/optout. > > > > -- > > 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/FFC3A2C1-51A0-4A2D-9D94-EEF0C511C5A6%40gmail.com. > > For more options, visit https://groups.google.com/d/optout. > > > > -- > > 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/CAOs3Lp7DtTtDdmaYHp%3DnKAxD% > 2B-_SU7JtBqbyNMpPDRdqpnjTNw%40mail.gmail.com. > > For more options, visit https://groups.google.com/d/optout. > > -- > 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/63341965-80C9-457B-B6C8-766C094869EA%40gmail.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To
Re: Load Template without rendering/parsing
I am not sure what you mean. I have this is urls.py # Root view, goes to 'app.home.views.page' (r'^$', 'app.home.views.page'), and the code below in page() in views.py, django routes ‘/‘ to that view and it renders the home page. Or you could use {% ssi %} to include the angular stuff. François > On Mar 16, 2015, at 9:01 AM, Guilherme Lealwrote: > > This solution crossed my mind, and the only down side that i see on it, is > that i cant use the "template.loader" logic for finding the right template. > > Em seg, 16 de mar de 2015 às 09:59, François Schiettecatte > escreveu: > You can just read the file content and return it with an HttpResponse(), like > this: > > > # File handle > fileHandle = None > > # Open the file, return a 404 if failed > try: > fileHandle = open(filePath, 'r') > except IOError: > raise Http404() > ># Return the file > return HttpResponse(content=fileHandle.read(), content_type=’text/html') > > François > > > > On Mar 16, 2015, at 8:49 AM, Guilherme Leal wrote: > > > > Hello! > > > > Anyone knows a way to load a template file WITHOUT parsing/rendering it? > > > > To ilustrate a bit more: > > > > I have a django app serving a restfull api, and everithing is just fine > > with it. The front end that consumes this api, is an Angular.js single page > > app. To centralize the routing logic, what i want to do is to let django to > > serve the "index.html" of this app. The only problem is, when i load the > > html of the front end (through "django.template.loader.get_template"), the > > template engine tries to parse it, and throws an exception because this > > "template" has the angularjs template tags on it. > > > > What i need is: > > - Load the template without parsing/rendering it > > OR > > - Serve this html document as static in production (the static serving view > > only works when debug is activated) > > > > Thanx in advance! > > > > -- > > 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/CAOs3Lp43aDqXDSfNNcH10gUvAZB-3UazGEL45bW59t-6Hyay9Q%40mail.gmail.com. > > For more options, visit https://groups.google.com/d/optout. > > -- > 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/FFC3A2C1-51A0-4A2D-9D94-EEF0C511C5A6%40gmail.com. > For more options, visit https://groups.google.com/d/optout. > > -- > 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/CAOs3Lp7DtTtDdmaYHp%3DnKAxD%2B-_SU7JtBqbyNMpPDRdqpnjTNw%40mail.gmail.com. > For more options, visit https://groups.google.com/d/optout. -- 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/63341965-80C9-457B-B6C8-766C094869EA%40gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: Load Template without rendering/parsing
This solution crossed my mind, and the only down side that i see on it, is that i cant use the "template.loader" logic for finding the right template. Em seg, 16 de mar de 2015 às 09:59, François Schiettecatte < fschietteca...@gmail.com> escreveu: > You can just read the file content and return it with an HttpResponse(), > like this: > > > # File handle > fileHandle = None > > # Open the file, return a 404 if failed > try: > fileHandle = open(filePath, 'r') > except IOError: > raise Http404() > ># Return the file > return HttpResponse(content=fileHandle.read(), > content_type=’text/html') > > François > > > > On Mar 16, 2015, at 8:49 AM, Guilherme Lealwrote: > > > > Hello! > > > > Anyone knows a way to load a template file WITHOUT parsing/rendering it? > > > > To ilustrate a bit more: > > > > I have a django app serving a restfull api, and everithing is just fine > with it. The front end that consumes this api, is an Angular.js single page > app. To centralize the routing logic, what i want to do is to let django to > serve the "index.html" of this app. The only problem is, when i load the > html of the front end (through "django.template.loader.get_template"), > the template engine tries to parse it, and throws an exception because this > "template" has the angularjs template tags on it. > > > > What i need is: > > - Load the template without parsing/rendering it > > OR > > - Serve this html document as static in production (the static serving > view only works when debug is activated) > > > > Thanx in advance! > > > > -- > > 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/CAOs3Lp43aDqXDSfNNcH10gUvAZB- > 3UazGEL45bW59t-6Hyay9Q%40mail.gmail.com. > > For more options, visit https://groups.google.com/d/optout. > > -- > 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/FFC3A2C1-51A0-4A2D-9D94-EEF0C511C5A6%40gmail.com. > For more options, visit https://groups.google.com/d/optout. > -- 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/CAOs3Lp7DtTtDdmaYHp%3DnKAxD%2B-_SU7JtBqbyNMpPDRdqpnjTNw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: Load Template without rendering/parsing
You can just read the file content and return it with an HttpResponse(), like this: # File handle fileHandle = None # Open the file, return a 404 if failed try: fileHandle = open(filePath, 'r') except IOError: raise Http404() # Return the file return HttpResponse(content=fileHandle.read(), content_type=’text/html') François > On Mar 16, 2015, at 8:49 AM, Guilherme Lealwrote: > > Hello! > > Anyone knows a way to load a template file WITHOUT parsing/rendering it? > > To ilustrate a bit more: > > I have a django app serving a restfull api, and everithing is just fine with > it. The front end that consumes this api, is an Angular.js single page app. > To centralize the routing logic, what i want to do is to let django to serve > the "index.html" of this app. The only problem is, when i load the html of > the front end (through "django.template.loader.get_template"), the template > engine tries to parse it, and throws an exception because this "template" has > the angularjs template tags on it. > > What i need is: > - Load the template without parsing/rendering it > OR > - Serve this html document as static in production (the static serving view > only works when debug is activated) > > Thanx in advance! > > -- > 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/CAOs3Lp43aDqXDSfNNcH10gUvAZB-3UazGEL45bW59t-6Hyay9Q%40mail.gmail.com. > For more options, visit https://groups.google.com/d/optout. -- 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/FFC3A2C1-51A0-4A2D-9D94-EEF0C511C5A6%40gmail.com. For more options, visit https://groups.google.com/d/optout.
Load Template without rendering/parsing
Hello! Anyone knows a way to load a template file WITHOUT parsing/rendering it? To ilustrate a bit more: I have a django app serving a restfull api, and everithing is just fine with it. The front end that consumes this api, is an Angular.js single page app. To centralize the routing logic, what i want to do is to let django to serve the "index.html" of this app. The only problem is, when i load the html of the front end (through "django.template.loader.get_template"), the template engine tries to parse it, and throws an exception because this "template" has the angularjs template tags on it. What i need is: - Load the template without parsing/rendering it OR - Serve this html document as static in production (the static serving view only works when debug is activated) Thanx in advance! -- 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/CAOs3Lp43aDqXDSfNNcH10gUvAZB-3UazGEL45bW59t-6Hyay9Q%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.