Ignore:
Timestamp:
Jun 28, 2013, 9:02:44 PM (11 years ago)
Author:
lfaraone
Message:
Additional updates for Django 1.4/1.5: static files, admin interface, README

Here we provide proper support for static files on Scripts, see
	<https://docs.djangoproject.com/en/1.4/howto/static-files/>

This means we designate a path for static files (~/web_scripts/$name/static)
and refer to the static files by their full username.scripts.mit.edu url over
HTTPS. This should work even if the user deploys the app on a subdomain or a
non-MIT hostname.

At the same time, we fix the urls.py rule to enable the admin interface,
which broke with the new URL pattern syntax a while ago. 

Finally, we run collectstatic to ensure that the relevant files are copied over.

In addition, a README was added to the web_scripts directory to help avoid
confusion over "where're my files?".

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/locker/deploy/bin/django

    r2370 r2441  
    3535close FASTCGI;
    3636chmod 0755, "index.fcgi";
     37
     38open README, ">README.txt";
     39print README <<EOF;
     40This directory contains index.fcgi, a script that serves up your Django site.
     41
     42To modify your Django project access the files in
     43        /mit/$user/Scripts/django/$name
     44
     45Files placed in this directory will be served directly to users without
     46being processed by Django.
     47
     48Static files live in the "static" subdirectory; you should not add things
     49there directly but instead place them with the relevant application as you
     50normally would, then run "python manage.py collectstatic" from the above
     51directory; see <https://docs.djangoproject.com/en/1.5/howto/static-files/>.
     52
     53  -- Scripts Team 2013-06-28
     54EOF
     55close README;
     56chmod 0555, "README.txt";
    3757
    3858open HTACCESS, ">.htaccess";
     
    7393  } elsif (/Chicago/) {
    7494    $_ =~ s/Chicago/New_York/;
    75   } elsif (/^ADMIN_MEDIA_PREFIX/) {
    76     $_ = "ADMIN_MEDIA_PREFIX = '/__scripts/django/media/'";
     95  } elsif (/^STATIC_URL/) {
     96    $_ = "STATIC_URL = '//$USER.$server/$name/static/'";
     97  } elsif (/^STATIC_ROOT/) {
     98    $_ = "STATIC_ROOT = '/mit/$USER/web_scripts/$addrend/static/'";
    7799  } elsif (/^INSTALLED_APPS/) {
    78100    print NEWSETTINGS "$_\n";
     
    99121  } elsif (/^#.*admin.autodiscover/) {
    100122    $_ =~ s/^# *//;
    101   } elsif (/^ *# *\(r\'\^admin\//) {
     123  } elsif (/^ *# url\(r\'\^admin\//) {
    102124    $_ =~ s/# *//;
    103125  }
     
    109131
    110132chdir "..";
     133
     134system(qw{python manage.py collectstatic --noinput}) == 0 or die "\nFailed to collect static files.\n\n";
    111135
    112136print "Initializing your project's SQL database schema...\n";
Note: See TracChangeset for help on using the changeset viewer.