<div dir="ltr">Dear Kieran,<div><br></div><div>Thank you, you helped a lot.</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Feb 17, 2014 at 6:01 AM, Kieran Spear <span dir="ltr"><<a href="mailto:kispear@gmail.com" target="_blank">kispear@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
STATIC_URL requires a RequestContext when rendering:<br>
<br>
<a href="http://stackoverflow.com/a/5478944" target="_blank">http://stackoverflow.com/a/5478944</a><br>
<br>
You can also use django.shortcuts.render.<br>
<br>
Cheers,<br>
Kieran<br>
<div><div class="h5"><br>
<br>
<br>
On 16 February 2014 00:37, Andrii L <<a href="mailto:postmaster.lists@gmail.com">postmaster.lists@gmail.com</a>> wrote:<br>
> Hello,<br>
><br>
> I would really appreciate if you help me understand the following exception:<br>
><br>
> ---<br>
> 'horizon/js/horizon.js' isn't accessible via COMPRESS_URL ('/static/') and<br>
> can't be compressed<br>
><br>
> Request URL: <a href="http://10.100.0.1/project/newpanel" target="_blank">http://10.100.0.1/project/newpanel</a><br>
> Django Version: 1.4.10<br>
> Exception Type: UncompressableFileError<br>
> Exception Value:<br>
> 'horizon/js/horizon.js' isn't accessible via COMPRESS_URL ('/static/') and<br>
> can't be compressed<br>
> Exception Location:<br>
> /usr/local/lib/python2.7/dist-packages/compressor/base.py in get_basename,<br>
> line 75<br>
> Python Executable: /usr/bin/python<br>
> Python Version: 2.7.3<br>
><br>
> Error during template rendering<br>
> In template /opt/stack/horizon/horizon/templates/horizon/_conf.html, error<br>
> at line 3<br>
><br>
> 1 {% load compress %}<br>
> 2<br>
> 3 {% compress js %}<br>
> 4 <script src='{{ STATIC_URL }}horizon/js/horizon.js' type='text/javascript'<br>
> charset='utf-8'></script><br>
> 5 <script src='{{ STATIC_URL }}horizon/js/horizon.conf.js'<br>
> type='text/javascript' charset='utf-8'></script><br>
> ---<br>
><br>
> What I am trying to do is to return any variable to template with the help<br>
> of render_to_response(). I set up default Devstack installation and created<br>
> a simple new panel under the Project dashboard.<br>
><br>
> It's really basic and just to prove the concept is working:<br>
><br>
> urls.py<br>
><br>
> from django.conf.urls.defaults import url, patterns<br>
> from .views import MyView<br>
> urlpatterns = patterns('',<br>
> url(r'^$', MyView.as_view(), name='index'),<br>
> )<br>
><br>
> views.py<br>
><br>
> from django.shortcuts import render_to_response<br>
> class MyView(View):<br>
> def get(self, request):<br>
> date_format = '%Y-%m-%d %H:%M:%S'<br>
> now = datetime.datetime.now()<br>
> return render_to_response('project/newpanel/index.html',<br>
> {'current_date': now.strftime(date_format)})<br>
><br>
> index.html<br>
><br>
> {% extends "base.html" %}<br>
> {% load i18n sizeformat %}<br>
> {% block title %}{% trans "New Panel" %}{% endblock %}<br>
> {% block main %}<br>
> {{ current_date }}<br>
> {% endblock %}<br>
><br>
> As I see my template was identified. Django is trying to extend base.html<br>
> and for some reasons fails on _conf.html.<br>
><br>
> I have COMPRESS_ENABLED = False in settings.py.<br>
><br>
> I know that some Horizon classes such as APIView or MultiTableView already<br>
> define method get() which returns self.render_to_response(context). But I<br>
> would like to start with something simple. I am not building any new table<br>
> for now. Although, maybe it's not possible to use render_to_response in<br>
> Horizon without using those classes?<br>
><br>
> Thank you for your help.<br>
><br>
</div></div>> _______________________________________________<br>
> Mailing list: <a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack</a><br>
> Post to : <a href="mailto:openstack@lists.openstack.org">openstack@lists.openstack.org</a><br>
> Unsubscribe : <a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack" target="_blank">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack</a><br>
><br>
</blockquote></div><br></div>