Well, this doesn't work completely. Consider the (static) tree:
/client index.html /apps another.html /css style.css /js my.js I need to serve this whole static tree out of /. On Tuesday, April 21, 2015 at 10:08:26 PM UTC-4, LiteWait wrote: > > I have no clue why this works, but I added the /client directory (full > path) to STATICFILE_DIRS and... > > from django.conf import settings > if settings.DEBUG: > urlpatterns += patterns( > 'django.contrib.staticfiles.views', > url(r'^(?:index.html)?$', 'serve', kwargs={'path': 'index.html'}), > url(r'^(?P<path>(?:js|css|img)/.*)$', 'serve'), > > > Now /client/index.html is served up fine, as well as Django normal routes > like /admin, /api, etc. I really wish I understood this better. > > > > On Tuesday, April 21, 2015 at 4:02:24 PM UTC-4, ke1g wrote: >> >> That may work for most static things. The question is whether the static >> server is happy with an empty path, assuming that you're trying to serve >> "/" this way. If not, you might add a separate (earlier) pattern of r'^$' >> that specifies a path in the extra parameters dictionary (where you have >> 'document_root', and you may want it's document_root to be different to >> avoid serving the home page at two urls). >> >> On Tue, Apr 21, 2015 at 1:56 PM, LiteWait <t...@toogopos.com> wrote: >> >>> Planning to host the client side of our application in production from a >>> proxy to an S3 site from Nginx. >>> >>> The problem is we'd like to mimic this behavior by serving / in Django >>> runserver using a static directory url() entry. >>> >>> I've read over >>> https://docs.djangoproject.com/en/1.4/howto/static-files/#serving-other-directories >>> but >>> I can't seem to make Django route / to my client directory. >>> >>> Idea is I have a project directory* /client *which contains index.html >>> along with all the other files for site, and when I hit >>> http://127.0.0.1:8000/ I want to serve up >>> *<projectdirectory>/client/index.html.* >>> >>> Not sure the following will work because I don't think you can't have a >>> STATIC_URL = '/', right? >>> >>> from django.contrib.staticfiles.urls import staticfiles_urlpatterns >>> urlpatterns += staticfiles_urlpatterns() >>> >>> >>> This one seems to make more sense, but I am not clear on what URL >>> pattern could pull this off.. >>> >>> if settings.DEBUG: >>> urlpatterns += patterns('', >>> url(r'^(?P<path>.*)$', 'django.views.static.serve', {'document_root': >>> '/client',}), >>> ) >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Django users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to django-users...@googlegroups.com. >>> To post to this group, send email to django...@googlegroups.com. >>> Visit this group at http://groups.google.com/group/django-users. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/django-users/ffdc58f3-e10c-46df-b14f-ec4bc02c0c70%40googlegroups.com >>> >>> <https://groups.google.com/d/msgid/django-users/ffdc58f3-e10c-46df-b14f-ec4bc02c0c70%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5ba4b639-48df-4c3b-8fb8-00a1a166f58e%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.