0

I have a basic django app with django rest framework. I have deployed it to Azure Web App and it working fine except the I am not able to serve the static files. I have the following in setting.py

BASE_DIR = os.path.dirname(os.path.dirname(__file__))
STATIC_ROOT = "/home/site/wwwroot/static/"  # Azure path
STATIC_URL = '/static/'

The application is looking for www.domain.com/static/". I did ran python manage.py collectstatic file on azure and it does create a directory will all the file at the above location.

Not sure what's wrong, may be something to do with how azure containiser the application. Any help would be much appreciated

SharePointer
  • 169
  • 9
  • 1
    https://stackoverflow.com/a/65817361/7077417 or https://learn.microsoft.com/en-us/azure/app-service/configure-language-python#serve-static-files-for-django-apps – dan webb Aug 06 '21 at 19:24
  • 1
    thanks. Adding the Url in the url.py did the trick. Thanks – SharePointer Aug 06 '21 at 20:06

1 Answers1

0

Thank you dan webb. Posting your suggestions as answer to help other community members.

Add the URL in url.py as per below code

**from django.conf import settings**

**from django.conf.urls.static import static**

**urlpatterns = [**

**path('myapp/', include('myapp.urls')),**

**path('admin/', admin.site.urls),**

**] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)**
SaiSakethGuduru
  • 2,218
  • 1
  • 5
  • 15