Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6665067
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:41:01+00:00 2026-05-26T02:41:01+00:00

In my Django project, I have static folders for each app, app1/static/, app2/static, etc.

  • 0

In my Django project, I have static folders for each app, app1/static/, app2/static, etc. It works fine with the development server.

However when I switch to use Django development server + nginx through fastcgi. There’s a problem that I can only map /static to one location. Is it possible, in Nginx, to map app1/static/, app2/static, etc to url /static.

The following config does not seem to work. What’s the correct way to achieve it? Thanks

location ^~ /static/ {
    root "app1/static/";app2/static;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T02:41:01+00:00Added an answer on May 26, 2026 at 2:41 am

    You should follow https://docs.djangoproject.com/en/dev/howto/static-files/.

    What it says is that you serve your files from static/ sub-folders in your app-folders. In your templates you use {{ STATIC_URL }} or in older versions {% get_static_prefix %}. In debug mode under the development server Django will directly serve the files from the static sub-folders in your app-folders.

    When you switch to nginx, you run collectstatic as Aviral suggests. This collects all files from the static/ sub-folders into the STATIC_ROOT folder. In order to not have all files in one folder, I would suggest to use static/app-name folders in your apps. In this case STATIC_ROOT will be populated with distinct app-name sub-folders and the static files for each app are separated. The templates must refer to files like {{ STATIC_URL }}/app-name/my_static_image.jpg.

    Your nginx config should than simply look like:

    location ^~ /static {
         root <your STATIC_ROOT path>;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a django project that works fine with the embedded server, but when
I have a django project that runs on a Linux server, and I've been
I have a Django-project which was running fine, until I made some changes I
I have a django project I keep on github. It worked perfectly fine on
I have django installed on my server with pymongo and mongoengine.My django project settings.py
My django project contains a folder STATIC in which there are it's child folders
I have a django project that I have been working on as a solo
So I have a django project I just created called 'coolprojectsite' the directory structure
I have a django project, but for some reason basic jquery isn't working. <html>
I have a Django project in which multiple processes are accessing the backend mysql

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.