nvbn / django-bower

Easy way to use bower with your django project
https://django-bower.readthedocs.io/
518 stars 74 forks source link

Django Bower and Django 1.7 #20

Open bh opened 10 years ago

bh commented 10 years ago

Hi,

Django bower does not work with Django 1.7 without my workaround:

# Hack to find bower components
STATICFILES_DIRS = (
    os.path.join(BOWER_COMPONENTS_ROOT, 'bower_components'),
)

So the static files will be found. But djangobower.finders.BowerFinder finds the files, when I try to create an object of BowerFinder in a Django shell.

olliewalsh commented 9 years ago

It works for me™

I had to change jquery to components/jquery due to https://github.com/bower/bower/issues/859 but that has nothing to do with Django 1.7. Setting PROJECT_ROOT isn't necessary as BASE_DIR is already set to the same value:


INSTALLED_APP = (
    ...
    'djangobower',
    ...
)

STATIC_ROOT = os.path.join(BASE_DIR, 'static')

STATICFILES_FINDERS = (
    "django.contrib.staticfiles.finders.FileSystemFinder",
    "django.contrib.staticfiles.finders.AppDirectoriesFinder",
    'djangobower.finders.BowerFinder',
)

BOWER_COMPONENTS_ROOT = os.path.abspath(os.path.join(BASE_DIR, 'components'))

BOWER_INSTALLED_APPS = (
    'components/jquery',
)
darkpixel commented 9 years ago

Totally borked under 1.7 for me.

Ended up pulling it out entirely. I tweaked heroku-buildpack-bower so I could run with '--allow-root' (https://github.com/darkpixel/heroku-buildpack-bower) under dokku, then tweaked a few settings like so:

  PROJECT_PATH = os.path.dirname(os.path.abspath(__file__))
  STATIC_ROOT = 'static'
  STATIC_URL = '/static/'

  STATICFILES_DIRS = (
      os.path.join(PROJECT_PATH, 'static'),
      os.path.join(PROJECT_PATH, '../bower_components')
  )

  STATICFILES_FINDERS = (
      'django.contrib.staticfiles.finders.FileSystemFinder',
      'django.contrib.staticfiles.finders.AppDirectoriesFinder',
      'django.contrib.staticfiles.finders.DefaultStorageFinder',
  )
kivikakk commented 9 years ago

It doesn't™ work for me on 1.7. It's a mystery.

percy3d commented 9 years ago

I had a pathing issue too. I pointed my staticfiles_dirs. It seems the version do django-bower installed all the folders under 'components/static/vendor/bower/' Was confusing but the following worked for me based on my folder layout under the components

STATICFILES_DIRS = ( os.path.join(BASE_DIR, "components/static/vendor/bower/"), <-- the root where packages are installed by bower. )

Ichag commented 8 years ago

Using BOWER_COMPONENTS_ROOT = os.path.abspath(os.path.join(BASE_DIR, 'components')) works for me. It seams to need the os.path.abspath method call to find the components correctly.