Re: Redirect to html file
> Hi! If I have some html file somewhere (i.e. /var/file), how to > redirect user to it? It is not a template and not in a template > folder. Thanks :) "Redirect" probably isn't the word you wanted there. If you really meant "How do I make my view function display the contents of an arbitrary HTML file?", the answer is: def showvarfile(request): return HttpResponse(open('/var/file').read()) As you can see, it's your own Python code reading the file's contents and sending it back to the browser. So this works even if '/var/file' isn't in a directory that your webserver is serving. That comes with some caveats, of course -- it's usually not the best way to do things, and is not as efficient as just letting the webserver serve it -- but I think that's what you were asking for... --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Redirect to html file
On Mon, Jun 29, 2009 at 6:11 AM, Daniel Rosemanwrote: > > On Jun 29, 9:23 am, alecs wrote: > > Hi! If I have some html file somewhere (i.e. /var/file), how to > > redirect user to it? It is not a template and not in a template > > folder. Thanks :) > > It needs to be somewhere the webserver can see it. Ideally you'd put > in the same place as the rest of your static content (CSS, JS), then > you can use the MEDIA_URL setting to access it. > -- > DR. > > > Alternatively you could just render it using a direct to template generic view, since just about any static HTML is a valid template file. Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: Redirect to html file
On Jun 29, 9:23 am, alecswrote: > Hi! If I have some html file somewhere (i.e. /var/file), how to > redirect user to it? It is not a template and not in a template > folder. Thanks :) It needs to be somewhere the webserver can see it. Ideally you'd put in the same place as the rest of your static content (CSS, JS), then you can use the MEDIA_URL setting to access it. -- DR. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Redirect to html file
Hi! If I have some html file somewhere (i.e. /var/file), how to redirect user to it? It is not a template and not in a template folder. Thanks :) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---