19๐
Note: The multi buildpack is a much nicer way to accomplish this these days ๐
Iโve created a fork of the official Python heroku buildpack that allows an optional npm_requirements.txt
for installing such dependencies.
I am now using coffeescript and less-css with django-compressor on heroku ๐
https://github.com/jiaaro/heroku-buildpack-django
Edit: To switch to my buildback from the standard buildpack:
-
use the
heroku
command line app to set theBUILDPACK_URL
environment variable:heroku config:add BUILDPACK_URL=git://github.com/jiaaro/heroku-buildpack-django.git
34๐
If you want to avoid maintaining a custom buildpack, you can use the multi buildpack.
Using the multi buildpack is super simple:
- Run
heroku config:add BUILDPACK_URL=https://github.com/ddollar/heroku-buildpack-multi.git
- Create a .buildpacks file in the root of your repository with two lines:
https://github.com/heroku/heroku-buildpack-nodejs.git
https://github.com/heroku/heroku-buildpack-python.git
- Create a package.json file with your npm dependencies.
- Run
npm install
- [Django]-Django โ user permissions to certain views?
- [Django]-Django change default runserver port
- [Django]-Django {% with %} tags within {% if %} {% else %} tags?
3๐
You can create your own buildpack, that mix nodejs buildbpack and python buildpack. Or compile your CoffeeScript on your machine and put it on S3.
- [Django]-What is the purpose of apps.py in Django 1.9?
- [Django]-Django date format 'dd-mm-yyyy'
- [Django]-Django โ Rotating File Handler stuck when file is equal to maxBytes
3๐
I found this question in Google while solving the same problem for myself.
I merged two official buildpacks (python and nodejs), so now one can have Django project with standard npm-description file package.json
by running this command:
heroku config:add BUILDPACK_URL=https://github.com/podshumok/heroku-buildpack-python
This solution differs from Jiaaroโs one in the following:
- it is based on the newer (dec 12) versions of buildpacks (for example, it runs collectstatic on deployment)
- you need correct
package.json
file (at least name and version of your product should be specified in this file) - npm dependencies should be listed in
package.json
- [Django]-In a django model custom save() method, how should you identify a new object?
- [Django]-Performing a getattr() style lookup in a django template
- [Django]-Error when using django.template
3๐
@Jiaaro โs solution didnโt work for meโฆ Causes some weird errorโฆ /:
File "almalinks/manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
ImportError: No module named django.core.management
Was too tired to deal with it, so I looked around and I found this nifty resource:
โ The heroku-django cookbook
They explain how you can add your own scripts that hook into herokuโs default buildpacks.
Worked like a charm. ๐
- [Django]-Django post_save() signal implementation
- [Django]-How can I render a ManyToManyField as checkboxes?
- [Django]-Django and client-side javascript templates
1๐
Things have changed in Heroku land
There is no need for multi build packs, .builpack files, or custom build packs. Simply add the required official heroku build packs to your heroku app and they will execute in the order entered. Use the index option to reorder them as required.
heroku buildpacks:add --index 1 heroku/nodejs -a your_app_name
There is also no need for, gunt tasks, apps like django-bower, or other specialized tools that take up server resources and slow build time.
You can check out my tutorial on how to seamlessly integrate Django + Bower + Heroku here.
- [Django]-How to keep all my django applications in specific folder
- [Django]-(fields.E300) Field defines a relation with model which is either not installed, or is abstract
- [Django]-How to set another Inline title in Django Admin?