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