nvbn / django-bower

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

Don't depend on settings.BASE_DIR, maybe? #28

Open mpasternak opened 9 years ago

mpasternak commented 9 years ago

Hi,

this is a part of my traceback, package built from today's git checkout:

  File "/var/lib/jenkins/shiningpanda/jobs/5a1cd455/virtualenvs/d41d8cd9/local/lib/python2.7/site-packages/djangobower/conf.py", line 5, in <module>
    COMPONENTS_ROOT = getattr(settings, 'BOWER_COMPONENTS_ROOT', settings.BASE_DIR)
  File "/var/lib/jenkins/shiningpanda/jobs/5a1cd455/virtualenvs/d41d8cd9/local/lib/python2.7/site-packages/django/conf/__init__.py", line 47, in __getattr__
    return getattr(self._wrapped, name)
AttributeError: 'Settings' object has no attribute 'BASE_DIR'

I don't have settings.BASE_DIR so it breaks, even if I have BOWER_COMPONENTS_ROOT defined.

Is there a policy for BASE_DIR in django settings file? Do I need to have it?

On the other hand, what reasonable default can you choose for BASE_DIR? Maybe it is better to break, because djangobower needs to write to filesystem, so we rather have a defined place where it writes instead of assuming something like /tmp...

darkpixel commented 9 years ago

Newer versions of django include something like this in the autogenerated settings.py:

import os
PROJECT_PATH = os.path.dirname(os.path.abspath(__file__))              
mpasternak commented 9 years ago

PROJECT_PATH doesn't sound like BASE_DIR te me :-)

I'd just handle the failure more gracefully. I think a traceback with explanation, what does django-bower really need from the settings.py file would be okay.