Assets Management#

from shopyo.api.assets import get_static

(Important) This assumes asset is in moduleorbox/static

In the case of a module in box:

def img_test_box():
    return '<img src="{}">'.format(get_static('box__qwerty/modulez', 'shop.png'))

In the case of a module outside box

def img_test_module():
    return '<img src="{}">'.format(get_static('modulez', 'shop.png'))

If DEBUG True, it will be served from the module’s static folder.

If DEBUG False, it will be served from main static folder. Make sure to run

python collectstatic


You can test the difference by running

shopyo run


shopyo --config=production run

Your code remains the same. Just the location changes.

Just if using apache, alias /static to server from main static folder