2016-05-13 15 views
1

Ich habe eine Website auf Django 1.2.5, die nicht die Staticfiles App enthält. Ich habe installiert jedoch die Static App über pip:S3 Speicherung von statischen Dateien mit Staticfiles App in Django 1.2.5 möglich?

sudo pip install django-staticfiles 

ich dann die Static App settings.py: aber

INSTALLED_APPS += (
    'staticfiles', 

wenn ich den Server einen bekommen einen 502 Bad Gateway Fehler neu zu starten und die folgende Fehler in /var/log/uwsgi/app/my-site.log:

Traceback (most recent call last): 
File "/var/projects/my-site/env/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 248, in __call__ 
    response = self.get_response(request) 
File "/var/projects/my-site/env/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 141, in get_response 
    return self.handle_uncaught_exception(request, resolver, sys.exc_info()) 
File "/var/projects/my-site/env/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 165, in handle_uncaught_exception 
    return debug.technical_500_response(request, *exc_info) 
File "/var/projects/my-site/env/local/lib/python2.7/site-packages/django/views/debug.py", line 59, in technical_500_response 
html = reporter.get_traceback_html() 
File "/var/projects/my-site/env/local/lib/python2.7/site-packages/django/views/debug.py", line 141, in get_traceback_html 
    return t.render(c) 
File "/var/projects/my-site/env/local/lib/python2.7/site-packages/django/template/__init__.py", line 173, in render 
    return self._render(context) 
File "/var/projects/my-site/env/local/lib/python2.7/site-packages/django/template/__init__.py", line 167, in _render 
    return self.nodelist.render(context) 
File "/var/projects/my-site/env/local/lib/python2.7/site-packages/django/template/__init__.py", line 796, in render 
bits.append(self.render_node(node, context)) 
File "/var/projects/my-site/env/local/lib/python2.7/site-packages/django/template/__init__.py", line 809, in render_node 
    return node.render(context) 
File "/var/projects/my-site/env/local/lib/python2.7/site-packages/django/template/__init__.py", line 844, in render 
output = self.filter_expression.resolve(context) 
File "/var/projects/my-site/env/local/lib/python2.7/site-packages/django/template/__init__.py", line 579, in resolve 
new_obj = func(obj, *arg_vals) 
File "/var/projects/my-site/env/local/lib/python2.7/site-packages/django/template/defaultfilters.py", line 682, in date 
    return format(value, arg) 
File "/var/projects/my-site/env/local/lib/python2.7/site-packages/django/utils/dateformat.py", line 281, in format 
    return df.format(format_string) 
File "/var/projects/my-site/env/local/lib/python2.7/site-packages/django/utils/dateformat.py", line 30, in format 
pieces.append(force_unicode(getattr(self, piece)())) 
File "/var/projects/my-site/env/local/lib/python2.7/site-packages/django/utils/dateformat.py", line 187, in r 
    return self.format('D, j M Y H:i:s O') 
File "/var/projects/my-site/env/local/lib/python2.7/site-packages/django/utils/dateformat.py", line 30, in format 
pieces.append(force_unicode(getattr(self, piece)())) 
File "/var/projects/my-site/env/local/lib/python2.7/site-packages/django/utils/encoding.py", line 66, in force_unicode 
s = unicode(s) 
File "/var/projects/my-site/env/local/lib/python2.7/site-packages/django/utils/functional.py", line 206, in __unicode_cast 
    return self.__func(*self.__args, **self.__kw) 
File "/var/projects/my-site/env/local/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 55, in ugettext 
    return real_ugettext(message) 
File "/var/projects/my-site/env/local/lib/python2.7/site-packages/django/utils/functional.py", line 55, in _curried 
    return _curried_func(*(args+moreargs), **dict(kwargs, **morekwargs)) 
File "/var/projects/my-site/env/local/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 36, in delayed_loader 
    return getattr(trans, real_name)(*args, **kwargs) 
File "/var/projects/my-site/env/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 276, in ugettext 
    return do_translate(message, 'ugettext') 
File "/var/projects/my-site/env/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 266, in do_translate 
_default = translation(settings.LANGUAGE_CODE) 
File "/var/projects/my-site/env/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 176, in translation 
default_translation = _fetch(settings.LANGUAGE_CODE) 
File "/var/projects/my-site/env/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 159, in _fetch 
app = import_module(appname) 
File "/var/projects/my-site/env/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module 
__import__(name) 
ImportError: No module named staticfiles 

aber ich Static importieren kann, wenn ich den folgenden Befehl aus meinem virtualenv Ordner ausführen:

$ python manage.py shell 
Python 2.7.6 (default, Mar 22 2014, 22:59:56) 
[GCC 4.8.2] on linux2 
Type "help", "copyright", "credits" or "license" for more information. 
(InteractiveConsole) 
>>> import staticfiles 
>>> 

Im Grunde versuche ich, die statischen Dateien S3 nach diesem Blog-Post zu verschieben:

https://www.caktusgroup.com/blog/2014/11/10/Using-Amazon-S3-to-store-your-Django-sites-static-and-media-files/

Ist es möglich, die Static app in Django 1.2.5 zu verwenden, oder muss ich Django aufwerten?

Ich würde lieber nicht Django upgraden, weil ich sicher bin, dass dies viele andere Teile der Website brechen wird.

Welche anderen Optionen gibt es? Ich nehme an, dass es möglich wäre, stattdessen Boto zu verwenden?

+0

Mein Fehler: Ich habe meine virtualenv nicht aktiviert war, als ich den Import Static Befehl ausgeführt wurde. Ich habe '/ var/projects/meine-site/env/bin/activate' then dann' python manage.py shell' dann 'python manage.py shell Python 2.7.6 (Standard, Mär 22 2014, 22:59: 56) [GCC 4.8.2] unter linux2 Geben Sie "help", "copyright", "credits" oder "license" ein, um weitere Informationen zu erhalten. (InteractiveConsole) >>> import Static Traceback (jüngste Aufforderung zuletzt): File "" Linie 1 in Import: Kein Modul mit dem Namen staticfiles'. Also nehme ich an, dass diese Methode zum Speichern von Dateien auf S3 mit Django <1.3 nicht möglich ist? – James

+0

Es klingt, als hättest du 'staticfiles' nicht innerhalb des virtualenv installiert. Do 'source/var/projects/meine-site/env/bin/activate' dann' pip install django-staticfiles' (sudo sollte nicht benötigt werden). – Alasdair

+0

Bitte aktualisieren Sie Django. 1.2.5 ist extrem veraltet, seitdem gab es viele Sicherheitsupdates. – Alasdair

Antwort

0

django-storage ist leider nicht mit Django 1.2.2 kompatibel.
Nach https://github.com/jschneier/django-storages

This library is usually compatible with the currently supported versions of Django. Check the trove classifiers in setup.py to be sure.