This is sort of a complex question so it will take a bit to explain. I'm not looking for a direct answer so any advice would be good. I have a Django app that uses a lot of CoffeeScript. To compile the CoffeeScript in the project I am using the app django-compressor. To use django-compressor I need to install nmp (node package manager). Unfortunately, I can't install npm on Heroku. Thus, I need to compile the CoffeeScript before it hits the Heroku servers. So I did that by setting up Fabric which is seeming to work well.
I am running into a problem no because I can get the compiled CoffeeScript as a static file but the templates still have the {% compress js %} *** {% endcompress %} tags in them because django-compressor does not regenerate new templates until run time.
Thus I am looking for advice on how to deploy the app to get ride of the template tags so that the app can be deployed on Heroku. I know it is a question with a lot of parts so any piece of advice would be super helpful!
I realize it's quite an old question - hit it occasionally
Just in case, here's the way to deal:
http://django_compressor.readthedocs.org/en/latest/usage/#pre-compression
http://django_compressor.readthedocs.org/en/latest/scenarios/#offline-compression
you could also commit the manifest.json file that django compressor generates (I'm assuming you're using it in offline mode) and then it will know which template blocks go to which compiled js/css files
Related
I am using django-compressor with a remote site on an Ubuntu server.
In my local environment, I'm on Windows, where django-compressor doesn't work.
Therefore I can't load django-compressor in my installed apps in my development settings (I have a settings folder with a base.py with dev.py and prod.py inheriting from that).
The problem is in my base.html template where I need to load the compress module
{% load compress %}
at the top of the document, and of course compress my css and js files accordingly.
Clearly this doesn't work on my local environment, with DEBUG set to True because the app can't exist in my installed apps. What I am trying to do is prevent this app being loaded dependent on the value of settings.DEBUG. I have tried an assignment tag which returns settings.DEBUG but that doesn't work.
Is this possible to achieve?
Many thanks in advance.
check out https://pypi.python.org/pypi/django-friendly-tag-loader/.
However, in theory django-compressor should work under windows, although it is not tested and might be broken at the moment. you could find out what the problem is and open a bug report or fix the issue.
Okay this might be a bad question but as someone who is new to django production I am a little lost
I have deployed my django project on Ubuntu 16.04 with a nginx, gunicorn and postgres stack. I am trying to make some simple template changes in the project (adding content in the .html templates) but the changes aren't showing up when I restart gunicorn and nginx.
All I can find online is reference to the collectstatic command which only seems to collect css, js and img...
How would I go about serving the updated template files?
Thanks in advance for your help.
I am running into an issue when I am deploying my app to heroku servers. On development (localhost:3000) everything works fine, when I launch the app some of my javascript is not working.
Solved the issue.
Turns out it had to do with bootstap reading the gems that were local on my machine. When I went to go push to heroku it was causing issues since I didnt precompile my assets and having all the gems was causing confusion so I removed them and added the bootstrap CDN and added it to the end of my body tag.
Maybe your assets are not precompiled. Check browser's console for missing files.
Heroku has very thorough documentation on getting the Rails Asset Pipeline working on there. Make sure you also use your browser development tools to help you identify 404 errors with assets or any other issues that can help you diagnose the problem.
I am trying to learn to use Google Polymer and wanted to use Django as I have some data crunching planned for the app and wanted to use python for it. The google Polymer website (Getting the code) highly suggested installing Polymer through bower. I went to the bower website and they said to install bower using nmp. I installed nmp (nodejs.org, I ran out of link privileges), installed bower and proceeded to install Polymer into my django virtual environment. I found a functioning website with it's files on Github (github.com/mc706/three_most_important_things) and compared their settings.py files to mine, and their directory hierarchy to see how they had implemented Polymer. It appears that they didn't use bower to install polymer, and they have polymer as an app inside their django project. I am not a django expert but I have used Bootstrap with it and had no problem. I assumed Polymer was just a set of css and js files that made code implementation easier. I have tried shifting the Polymer "components" around (first in bower-components, then static/components) and changed my link references to point there, but I still get a blank page when I render it. Can someone give me a simple file hierarchy example of where the polymer files should be stored and how to reference them? eg.
project
bin
include
lib
project
project main
project apps
static
static
components
There are only a view sites that mention django+polymer together, and normally it's a question about {{}} and {% verbatim %} usage. I can't seem to get to that point. Any setup advice would greatly appreciated.
I have a django project under a virtualenv.
I included the django-zurb-foundation 5.3.0 package to use foundation but this version only include static css files.
It's my first time using django and normally i use foundation with sass using bower and grunt.
How can i do to use the sass version of foundation?
What should be the files tree?
UPDATE
i installed django compressor and i got it work on local, it works perfectly, but i cannot get it to work on my production server:
on local env i have a CACHE folder with the css static files in it and the html page call correctly the file from there.
On the prod site instead, it doesnt create the CACHE folder and it doesnt render the path to it and it keeps the path to the scss file.
What am i doing wrong?
It seems like compressor isnt working on the prod server, i'm afraid i'm doing something wrong with django settings.py since i'm new to it.
any help?
I have heard of a few people using django-bower with foundation, personally I have not played with it but its worth looking into if you have not already.
I really can't find a reason to use a third party Django application to do that, using front-end frameworks like foundation or Bootstrap is as simple as compiling the less or sass source files to a css file and include it in your html (<link rel="stylesheet"...).
With Django you can use Bower and Grunt without any problem because they're independent and totally configurable to fill your needs. What I do with bower is to create a .bowerrc file at the same level of the bower.json file with the directory setting pointing to the main static folder, something like:
{
"directory": "my_django_app/static/bower_components"
}
Talking about the django-compressor app all that I can say is I don't recommend to use it in a production environment, it has some performance problems and personally I prefer the static files to be responsibility of the front-end dev instead of the back-end dev. For example you will need to have source maps for your javascript for debugging purposes and I don't remember if it's possible with this plugin.
Instead of using the django-compressor you can use a grunt plugin to to it, I've done one that may help you to do so: https://www.npmjs.org/package/grunt-django-compressor