django-systemjs icon indicating copy to clipboard operation
django-systemjs copied to clipboard

'NoneType' object has no attribute 'systemjs_bundling'

Open nmgeek opened this issue 8 years ago • 4 comments

This comes from the following lines in management/commands/systemjs_bundle.py:

        self.storage = copy(staticfiles_storage)
        self.storage.systemjs_bundling = True  # set flag to check later

I'm a pretty good python programmer but I'm not sure what is going on here. The copy() function isn't doing what the original programmer intended ... and the systemjs_bundling attribute is never used so maybe just dispense with that call to copy()?

BTW, I am using Python 2.7 and Django version 1.8

nmgeek avatar Nov 26 '16 00:11 nmgeek

Hi, I'm quite busy currently, just letting you know I haven't forgotten about this and will look into it asap!

sergei-maertens avatar Nov 30 '16 19:11 sergei-maertens

Okay, I took a quick look and I have a hunch what's going wrong.

Which staticfiles storage are you using? It's probably not inheriting from the storage shipping with this libary.

self.storage = copy(staticfiles_storage)

This is intentionally creating a shallow copy of the storage to not mess with the built in storage, since that's a lazily evaluated module attribute. That way, the only storage modifications are scoped to the bundle command and won't affect the behaviour of collectstatic.

self.storage.systemjs_bundling = True # set flag to check later

is used in https://github.com/sergei-maertens/django-systemjs/blob/develop/systemjs/storage.py#L47

sergei-maertens avatar Nov 30 '16 20:11 sergei-maertens

My settings do nothing special with staticfiles: no storage setting at all. The django.contrib.staticfiles app is installed then I have this setting:

STATICFILES_DIRS = (
    "../client/dist",
    "../client",
)

nmgeek avatar Dec 02 '16 15:12 nmgeek

I'll have to double check on that, I just checked the docs and they suggest only using the custom storage if you're using the Manifest based storage, so I'll set up a test project for that to verify that + figure out what's going wrong.

Thanks for the report!

sergei-maertens avatar Dec 02 '16 15:12 sergei-maertens