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 7896651
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:56:58+00:00 2026-06-03T07:56:58+00:00

I’m relatively new to Django (1.4) and I’m having a hard time understanding the

  • 0

I’m relatively new to Django (1.4) and I’m having a hard time understanding the philosophy behind static, media, and admin files. The structure of the project is different from one tutorial to another, and same thing for Webfaction(where I’ll be hosting my application). I would like to know what is the optimal way to organize it and with least pain and editing while deploying it to Webfaction, what is the point of static media, adn admin files?
Thank you in advance

  • 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-06-03T07:56:59+00:00Added an answer on June 3, 2026 at 7:56 am

    In essence you want to serve static files by django in development. Once you’re ready to go into production you want the server to do this for you (they are build to do it fast :-))

    Here’s a basic setup, once you login the server you run the collectstatic command to get all the staticfiles in the static-root folder, which your server points to (see the rewrite rules)

    ./manage.py collectstatic
    

    settings.py

        from os import path
        import socket
    
        PROJECT_ROOT = path.dirname(path.abspath(__file__)) #gets directory settings is in
    
        # Dynamic content is saved to here
        MEDIA_ROOT = path.join(PROJECT_ROOT,'media')
        # if ".webfaction.com" in socket.gethostname():
        #    MEDIA_URL = 'http://(dev.)yourdomain.com/media/'
        # else:
            MEDIA_URL = '/media/'
    
        # Static content is saved to here --
        STATIC_ROOT = path.join(PROJECT_ROOT,'static-root') # this folder is used to collect static files in production. not used in development
        STATIC_URL =  "/static/"
        STATICFILES_DIRS = (
            ('', path.join(PROJECT_ROOT,'static')), #store site-specific media here.
        )
    
        # List of finder classes that know how to find static files in
        # various locations.
        STATICFILES_FINDERS = (
            'django.contrib.staticfiles.finders.FileSystemFinder',
            'django.contrib.staticfiles.finders.AppDirectoriesFinder',
        #    'django.contrib.staticfiles.finders.DefaultStorageFinder',
        )
    

    settings_deployment.py

    from settings import *
    
    DEBUG = False
    TEMPLATE_DEBUG = DEBUG
    MEDIA_URL = "http://yourdomain.com/media/"
    

    urls.py

    ...other url patterns...
    
    if settings.DEBUG:
        urlpatterns += staticfiles_urlpatterns() #this serves static files and media files.
        #in case media is not served correctly
        urlpatterns += patterns('',
            url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {
                'document_root': settings.MEDIA_ROOT,
                }),
        )
    

    django.conf (lighttpd, this could be apache or nginx) but I believe webfaction has an app service to set this up easily

    $HTTP["host"] =~ "(^|\.)yourdomain\.com$" {
        fastcgi.server = (
            "/django.fcgi" => (
                "main" => (
                    "socket" => env.HOME + "/project/project.sock",
                    "check-local" => "disable",
                )
            ),
        )
        alias.url = (
            "/media" => env.HOME + "/project/media",
            "/static" => env.HOME + "/project/static-root",
        )
    
        url.rewrite-once = (
            "^(/media.*)$" => "$1",
            "^(/static.*)$" => "$1",
            "^/favicon\.ico$" => "/static/img/favicon.png",
            "^(/.*)$" => "/django.fcgi$1",
        )
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have thousands of HTML files to process using Groovy/Java and I need to
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have a bunch of posts stored in text files formatted in yaml/textile (from
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim

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.