Asset views

Serving assets in development

django_gears.views.serve(request, path, **kwargs)

Django Gears provides the serve() view for use in development. This view will process and serve any matching assets on the fly. This means you can simply reload your pages to see the latest changes.

Further, if no matching asset is found, serve() falls back to Django’s staticfiles.views.serve view. This means your application can happily serve static files alongside Gear’s assets.

The easiest way to make use of the serve() view in your application is to use the included gears_urlpatterns() function.

from django_gears.urls import gears_urlpatterns

# url definitions here

urlpatterns += gears_urlpatterns()

Sites using these urlpatterns will not need to use Django’s staticfiles urlpatterns.


Like staticfiles_urlpatterns, gears_urlpatterns only registers patterns when settings.Debug is True. This isn’t for production use. See the Deployment docs for more information.

Gears urlpatterns


Returns development urlpatterns for serving assets.

If settings.DEBUG is false, the returned urlpatterns will be empty.

Parameters:prefix – The url prefix to server assets under. Defaults to the GEARS_URL setting.