Can't serve static files in Django

Repository of web frameworks and applications for Microsoft IIS.
User avatar
Posts: 4
Joined: 15 May 2014, 13:17

Can't serve static files in Django

15 May 2014, 13:26

I'm brand new to Zoo, and IIS. Following the documentation, I've managed to get my Django app up and running on my local machine, even though Microsoft's web installer now serves up IIS 8.0, which delayed me a bit. The only problem I'm having now is that following the documentation to allow IIS to serve static files isn't working.

My web.config handlers section, as well as my django STATICFILE_DIRS, is shown below. I've triple checked the STATICFILE_DIRS path, and made sure it's correct. Please help. Thanks.

Code: Select all
  <handlers>

   <remove name="django.project#x86" />
   <remove name="django.project#x64" />

   <!-- Django or WSGI application over fastcgi -->
   <add name="python.project#x86" scriptProcessor="python.2.7.wsgi" path="*" verb="*" modules="HeliconZoo_x86" preCondition="bitness32" resourceType="Unspecified" requireAccess="Script" />
   <add name="python.project#x64" scriptProcessor="python.2.7.wsgi" path="*" verb="*" modules="HeliconZoo_x64" preCondition="bitness64" resourceType="Unspecified" requireAccess="Script" />

  </handlers>


Code: Select all
STATICFILES_DIRS = (
      # Put strings here, like "/home/html/static" or "C:/www/django/static".
      # Always use forward slashes, even on Windows.
      # Don't forget to use absolute paths, not relative paths.
      "C:/Users/shawn.holyoak/Documents/My Web Sites/ZooPythonProject/sdcgis/static",
   )

User avatar
Posts: 4
Joined: 15 May 2014, 13:17

Re: Can't serve static files in Django

15 May 2014, 13:40

I found out (and maybe this is an IIS thing) that Zoo doesn't use the STATICFILES_DIR for Django. I copied all my static files into the IIS static folder, and everything works fine. Maybe that could be added to the documentation for n00bs like me :)

User avatar
Posts: 110
Joined: 07 Mar 2012, 10:22

Re: Can't serve static files in Django

16 May 2014, 05:50

Hello,

The right way to deal with static file is
1. Specify STATIC_URL and STATIC_ROOT in settings.py,
2. Run 'manage.py collectstatic' to collect static files from from your django application to directory with static files (STATIC_ROOT),
3. Disable Helicon Zoo handler in STATIC_ROOT to allow process these files to IIS.

Link to Django docs: https://docs.djangoproject.com/en/dev/h ... tic-files/

Thank you.

Return to Helicon Zoo

Who is online

Users browsing this forum: No registered users and 5 guests