Django-fr

Forum

#1 09-10-2013 09:42:55

zirby
Membre
Inscription : 09-10-2013
Messages : 4

Django-admin : erreur stylesheet

Bonjour,
Je suis newbie en django.
Suivant un tuto, j'ai ajouté le répertoire 'STATIC' dans mon app de mon projet.
Cool ça marche. Sauf que !!  /admin m'envoie des errors depuis?

(je suis en UBUNTU 12.04LTS  python-2.7.3 Django-1.5.4 IDE: Aptana-Pydev)

AttributeError at /admin/
'tuple' object has no attribute 'startswith'
Request Method:    GET
Request URL:    http://127.0.0.1:8000/admin/
Django Version:    1.5.4
Exception Type:    AttributeError
Exception Value:   
'tuple' object has no attribute 'startswith'
Exception Location:    /usr/lib/python2.7/posixpath.py in isabs, line 53
Python Executable:    /usr/bin/python2.7
Python Version:    2.7.3
Python Path:   
['/home/zirby/Ubuntu One/dev/Django-Workspace/tracker',
'/home/zirby/Ubuntu One/dev/Django-Workspace/tracker',
'/usr/local/lib/python2.7/dist-packages/distribute-0.7.3-py2.7.egg',
'/usr/local/lib/python2.7/dist-packages/setuptools-1.1.6-py2.7.egg',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/PIL',
'/usr/lib/python2.7/dist-packages/gst-0.10',
'/usr/lib/python2.7/dist-packages/gtk-2.0',
'/usr/lib/python2.7/dist-packages/ubuntu-sso-client',
'/usr/lib/python2.7/dist-packages/ubuntuone-client',
'/usr/lib/python2.7/dist-packages/ubuntuone-control-panel',
'/usr/lib/python2.7/dist-packages/ubuntuone-couch',
'/usr/lib/python2.7/dist-packages/ubuntuone-installer',
'/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol']
Server time:    mer, 9 Oct 2013 10:21:34 +0200
Error during template rendering

In template /usr/local/lib/python2.7/dist-packages/django/contrib/admin/templates/admin/base.html, error at line 5
'tuple' object has no attribute 'startswith'
1    {% load admin_static %}<!DOCTYPE html>
2    <html lang="{{ LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif %}>
3    <head>
4    <title>{% block title %}{% endblock %}</title>
5    <link rel="stylesheet" type="text/css" href="{% block stylesheet %}{% static "admin/css/base.css" %}{% endblock %}" />
6    {% block extrastyle %}{% endblock %}
7    <!--[if lte IE 7]><link rel="stylesheet" type="text/css" href="{% block stylesheet_ie %}{% static "admin/css/ie.css" %}{% endblock %}" /><![endif]-->
8    {% if LANGUAGE_BIDI %}<link rel="stylesheet" type="text/css" href="{% block stylesheet_rtl %}{% static "admin/css/rtl.css" %}{% endblock %}" />{% endif %}
9    <script type="text/javascript">window.__admin_media_prefix__ = "{% filter escapejs %}{% static "admin/" %}{% endfilter %}";</script>
10    {% block extrahead %}{% endblock %}
11    {% block blockbots %}<meta name="robots" content="NONE,NOARCHIVE" />{% endblock %}
12    </head>
13    {% load i18n %}
14   
15    <body class="{% if is_popup %}popup {% endif %}{% block bodyclass %}{% endblock %}">

une idée ??

Hors ligne

#2 14-10-2013 07:13:37

Xavier Ordoquy
Administrateur
Lieu : Puteaux, France
Inscription : 12-10-2011
Messages : 312
Site Web

Re : Django-admin : erreur stylesheet

Bonjour,

Que valent STATIC_URL, STATIC_ROOT et STATICFILES_DIRS ?

Hors ligne

#3 14-10-2013 07:59:37

zirby
Membre
Inscription : 09-10-2013
Messages : 4

Re : Django-admin : erreur stylesheet

Bonjour Xavier,

voici settings.py

import os
PROJECT_ROOT=os.path.abspath(os.path.dirname(__file__))
.....

STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static'),

# URL prefix for static files.
# Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL = '/static/'

# Additional locations of static files
STATICFILES_DIRS = (
    # Put strings here, like "/home/html/static" or "C:/www/django/static".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
)

Hors ligne

#4 16-10-2013 07:52:55

Xavier Ordoquy
Administrateur
Lieu : Puteaux, France
Inscription : 12-10-2011
Messages : 312
Site Web

Re : Django-admin : erreur stylesheet

Bonjour,

STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static'),

La virgule en fin de ligne pose le souci. Au lieu d'avoir STATIC_ROOT = '.../static' vous avez STATIC_ROOT = ('..../static', )
La supprimer enlevera le tuple (d'où le message "'tuple' object has no attribute 'startswith'")

Hors ligne

#5 16-10-2013 08:16:23

zirby
Membre
Inscription : 09-10-2013
Messages : 4

Re : Django-admin : erreur stylesheet

Problème résolu :-)

merci Xavier

Hors ligne

Pied de page des forums