0

I have two apps under different URLs. But the static file dir is the same. So I'd need to tell to django that when /myapp/static/jpg.jpg is asked it would redirect it to /static/jpg.jpg and would do the same for myotherapp/static/jpg.jpg. This is simple todo in apache conf - just map /myapp/static/ to /static/. But can it be done in django?

Better example. I have www.myapp.com and www.myotherapp.com. They are on my server as localhost/myapp and localhost/myotherapp/ and static files are on localhost/static. So I can't access the static uri with URL

Mihkel L.
  • 1,543
  • 1
  • 27
  • 42
  • When you write about `/myapp/static/jpg.jpg` or `/static/jpg.jpg` do you mean local directory paths on the server or URLs used in a browser? – Ludwik Trammer Mar 21 '16 at 11:49
  • Why aren't you using the `static` tag? – rnevius Mar 21 '16 at 11:52
  • Add your apps static path in `STATICFILES_DIRS` variables in your `settings.py`. – mortymacs Mar 21 '16 at 11:53
  • @LudwikTrammer server URLs – Mihkel L. Mar 21 '16 at 11:58
  • 1
    @MihkelL. have a look into here: http://stackoverflow.com/questions/15706489/redirect-to-named-url-pattern-directly-from-urls-py-in-django – mortymacs Mar 21 '16 at 12:07
  • @Mortezaipo THis doesn't work in my case. The redirect doesn't go to the other app. even with `urlpatterns = [ url(r'^myapp/static/(?P.*)', RedirectView.as_view(url='/static/%(resource)s')), ..]` – Mihkel L. Mar 21 '16 at 14:15
  • @MihkelL. You can try it: separate your 'static' directory to some place else (like third app which just only has 'static' url). and then call it with url like: `http://file.myapp.com/static/`. – mortymacs Mar 22 '16 at 05:48

0 Answers0