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.
Related
I'm a bit confused by the folder structure the sphinx makes for its documentation when starting a fresh new Django project with cookiecutter.
I have my project set up in docker, as per instructions, everything is serving fine and I have the following folder structure for the documentation.
When I run the command make html in the docs container (or by using the docker-compose local.yml file) I get the following structure.
A new folder "html" is created and it's containing everything from the surrounding folders. Is this correct? Am I understanding the process correctly?
For me, it looks like some bad settings for some source folder somewhere.
I'm an experienced python dev, familiar with Docker as well, but I'm pretty new to Django and sphinx.
Can somebody please guide me to the right path, possibly share their Django sphinx docs workflow?
Thank you very much.
I have a Django aplication (+REST framework) with pluggable Django apps (which are discovered using distutils' entry points, and can be developed independetly from each other, and installed via pip). This works well so far.
The main app should provide a basic index.html which dynamically loads React components, and each app should be possible to add React components as plugins, which are combined on the frontend then.
But: How the heck am I supposed to place my client directories into each app, so that they are found for collecting all the static files?
Should I put a react app into /my-app1/client and /my-app2/client?
my-application/
core-app/
client/
react files etc
static/
models.py
...
plugin-app1/
client/
react files etc
static/
models.py
...
And tell Webpack/brunch/whatever to compile all the css/js etc files into /my-app1/static, followed by ./manage.py collectstatic then?
Is there a better approach to collect distributed react "plugin" in dfferent Django apps into one static directory?
Can brunch.io do this? Webpack? Another? Own script?
It would be nice to have something like brunch watch - to have hot-updated all changed files instantly. This works for one directory, but not for a distributed net of plugin directories, right?
Or is this completely thought wrong? Please help.
This might be a silly question stemming from unfamiliarity. I'm rewriting a project that was previously using Ember 1.7 in Ember 2.3, using Ember-cli v2.2
Now, in the old project, there were a couple of libraries being included manually on the index.html file, put in the scripts directory and then compiled. For example, let's say the JS asset I want to include is offline.js.
I understand that Ember-cli uses Bower and can be used to install bower components, like Bootstrap or moment.js and such. What about custom JS? I've put the file in offline.js, included it in index.html but that doesn't do anything.
I don't think I understand how to add/import vendor assets at all; how do add, say offline.js to the project and have it available throughout the application?
You should add the offline.js file to the vendor folder at the root of the project, and then in your ember-cli-build.js file add the following line:
app.import('vendor/offline.js');
This adds the offline.js file to the vendor.js which is built by default. You can see more documentation at the Ember CLI website.
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
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