Django-fr

Forum

#1 19-08-2012 22:31:22

Arnaud
Membre
Inscription : 16-06-2012
Messages : 14

[Résolu] Markitup : problème de chemins static

Bonsoir,

Je suis en train de m'arracher les quelques cheveux qu'il me reste sur l'intégration de markitup dans django-admin. Le site est encore en phase de développement, et après avoir testé tinymce, je voulais voir un peu autre chose. Si l'installation de tinymce et de ses plugins s'est passée sans soucis, ce n'est pas pareil avec markitup.

Les fichiers statiques ne sont pas "trouvés", bien que bien présents dans le dossier static. Dans ce même dossier se trouvent déjà les fichiers concernant django-admin, ce qui conduit aux messages paradoxaux ( du moins pour moi ) :

[19/Aug/2012 23:14:38] "GET /static/markitup/ajax_csrf.js HTTP/1.1" 404 1667
[19/Aug/2012 23:14:38] "GET /static/admin/js/calendar.js HTTP/1.1" 304 0
[19/Aug/2012 23:14:38] "GET /static/markitup/jquery.markitup.js HTTP/1.1" 404 1685
[19/Aug/2012 23:14:38] "GET /static/markitup/sets/markdown/set.js HTTP/1.1" 404 1691
[19/Aug/2012 23:14:38] "GET /static/admin/js/admin/DateTimeShortcuts.js HTTP/1.1" 304 0
[19/Aug/2012 23:14:38] "GET /static/admin/css/widgets.css HTTP/1.1" 304 0
[19/Aug/2012 23:14:38] "GET /static/markitup/skins/markitup/style.css HTTP/1.1" 404 1703
[19/Aug/2012 23:14:38] "GET /static/markitup/sets/markdown/style.css HTTP/1.1" 404 1700
[19/Aug/2012 23:14:38] "GET /static/markitup/ajax_csrf.js HTTP/1.1" 404 1667
[19/Aug/2012 23:14:38] "GET /static/markitup/jquery.markitup.js HTTP/1.1" 404 1685
[19/Aug/2012 23:14:38] "GET /static/markitup/sets/markdown/set.js HTTP/1.1" 404 1691
[19/Aug/2012 23:14:38] "GET /static/admin/img/nav-bg-reverse.gif HTTP/1.1" 304 0
[19/Aug/2012 23:14:38] "GET /static/admin/img/icon_addlink.gif HTTP/1.1" 304 0
[19/Aug/2012 23:14:38] "GET /static/admin/img/nav-bg.gif HTTP/1.1" 304 0
[19/Aug/2012 23:14:38] "GET /static/admin/img/default-bg.gif HTTP/1.1" 304 0
[19/Aug/2012 23:14:38] "GET /static/admin/img/icon_calendar.gif HTTP/1.1" 304 0
[19/Aug/2012 23:14:38] "GET /static/admin/img/icon_clock.gif HTTP/1.1" 304 0

Tout se passe bien pour admin, mais pas pour markitup. Pourtant ils sont là, je les vois, et pour limiter les soucis, j'ai même mis les droits à 777, sans résultat.

Voici les passages importants de settings.py ( django.contrib.staticfiles est activé ) :

STATIC_ROOT = '/home/arnaud/site/static/'
STATIC_URL = 'http://127.0.0.1:8000/static/'
MARKITUP_FILTER = ('markdown.markdown', {})
MARKITUP_SET = 'markitup/sets/markdown'
MARKITUP_SKIN = 'markitup/skins/markitup'
JQUERY_URL = '/media/js/jquery-1.7.1.min.js'

et dans urls.py :

url(r'^admin/', include(admin.site.urls)),
url(r'^static/(?P<path>.*)$', 'django.contrib.staticfiles.views.serve'),
url(r'^markitup/', include('markitup.urls')),

Merci smile

Dernière modification par Arnaud (21-08-2012 20:33:50)

Hors ligne

#2 20-08-2012 09:05:40

FoxMaSk
Membre
Inscription : 11-08-2010
Messages : 23
Site Web

Re : [Résolu] Markitup : problème de chemins static

bonjour,

on pourrait avoir un petit :

ls -Rl /home/arnaud/site/static/markitup

histoire de voir si jquery.markitup.js + les skins et règles (set)  sont bien dispo pour markitup ?

cordialement.

Hors ligne

#3 20-08-2012 09:53:15

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

Re : [Résolu] Markitup : problème de chemins static

Le 19 août 2012 à 23:31, Arnaud <akientz _AT_ gmx.de> a écrit :

> Bonsoir,

Hello

>

> STATIC_ROOT = '/home/arnaud/site/static/'
> STATIC_URL = 'http://127.0.0.1:8000/static/'
> MARKITUP_FILTER = ('markdown.markdown', {})
> MARKITUP_SET = 'markitup/sets/markdown'
> MARKITUP_SKIN = 'markitup/skins/markitup'
> JQUERY_URL = '/media/js/jquery-1.7.1.min.js'
>

Il y a confusion entre le STATIC_ROOT et le STATICFILES_DIRS

STATIC_ROOT est le répertoire dans lequel Django va copier les fichiers statiques collectés à partir des répertoires "static" des applications ainsi que dans les repertoires listés par STATICFILES_DIRS.
STATIC_ROOT n'est généralement utilisé qu'en production. Cette partie de l'arborescence est servie directement par Apache/Nginx/...
Pour le développement, ce sont les  STATICFILES_DIRS + les répertoires static des applications qui sont collectés par django.contrib.staticfiles.views.serve

Donc, tu remplaces ton STATIC_ROOT par STATICFILES_DIRS et ça devrait marcher (voir point 1 de https://docs.djangoproject.com/en/1.4/howto/static-files/#basic-usage)

Cordialement,
Xavier Ordoquy,
Linovia.

Hors ligne

#4 20-08-2012 20:19:15

Arnaud
Membre
Inscription : 16-06-2012
Messages : 14

Re : [Résolu] Markitup : problème de chemins static

Bonsoir,

FoxMaSk a écrit :

ls -Rl /home/arnaud/site/static/markitup

Voilà, tout est là :

static/markitup:
total 40K
-rwxrwxrwx 1 arnaud arnaud 1,2K août  19 18:46 ajax_csrf.js*
-rwxrwxrwx 1 arnaud arnaud  17K août  19 18:46 jquery.markitup.js*
-rwxrwxrwx 1 arnaud arnaud  113 août  19 18:46 preview.css*
drwxrwxrwx 6 arnaud arnaud 4,0K août  19 18:46 sets/
drwxrwxrwx 4 arnaud arnaud 4,0K août  19 18:46 skins/
drwxrwxrwx 2 arnaud arnaud 4,0K août  19 18:46 templates/

static/markitup/sets:
total 16K
drwxrwxrwx 3 arnaud arnaud 4,0K août  19 18:46 default/
drwxrwxrwx 3 arnaud arnaud 4,0K août  19 18:46 markdown/
drwxrwxrwx 3 arnaud arnaud 4,0K août  19 18:46 restructuredtext/
drwxrwxrwx 3 arnaud arnaud 4,0K août  19 18:46 textile/

static/markitup/sets/default:
total 12K
drwxrwxrwx 2 arnaud arnaud 4,0K août  19 18:46 images/
-rwxrwxrwx 1 arnaud arnaud 1,6K août  19 18:46 set.js*
-rwxrwxrwx 1 arnaud arnaud  722 août  19 18:46 style.css*

static/markitup/sets/default/images:
total 32K
-rwxrwxrwx 1 arnaud arnaud 304 août  19 18:46 bold.png*
-rwxrwxrwx 1 arnaud arnaud 667 août  19 18:46 clean.png*
-rwxrwxrwx 1 arnaud arnaud 516 août  19 18:46 image.png*
-rwxrwxrwx 1 arnaud arnaud 223 août  19 18:46 italic.png*
-rwxrwxrwx 1 arnaud arnaud 343 août  19 18:46 link.png*
-rwxrwxrwx 1 arnaud arnaud 606 août  19 18:46 picture.png*
-rwxrwxrwx 1 arnaud arnaud 537 août  19 18:46 preview.png*
-rwxrwxrwx 1 arnaud arnaud 269 août  19 18:46 stroke.png*

static/markitup/sets/markdown:
total 16K
drwxrwxrwx 2 arnaud arnaud 4,0K août  19 18:46 images/
-rwxrwxrwx 1 arnaud arnaud  319 août  19 18:46 readme.txt*
-rwxrwxrwx 1 arnaud arnaud 2,5K août  19 18:46 set.js*
-rwxrwxrwx 1 arnaud arnaud 1,3K août  19 18:46 style.css*

static/markitup/sets/markdown/images:
total 60K
-rwxrwxrwx 1 arnaud arnaud 304 août  19 18:46 bold.png*
-rwxrwxrwx 1 arnaud arnaud 859 août  19 18:46 code.png*
-rwxrwxrwx 1 arnaud arnaud 276 août  19 18:46 h1.png*
-rwxrwxrwx 1 arnaud arnaud 304 août  19 18:46 h2.png*
-rwxrwxrwx 1 arnaud arnaud 306 août  19 18:46 h3.png*
-rwxrwxrwx 1 arnaud arnaud 293 août  19 18:46 h4.png*
-rwxrwxrwx 1 arnaud arnaud 304 août  19 18:46 h5.png*
-rwxrwxrwx 1 arnaud arnaud 310 août  19 18:46 h6.png*
-rwxrwxrwx 1 arnaud arnaud 223 août  19 18:46 italic.png*
-rwxrwxrwx 1 arnaud arnaud 343 août  19 18:46 link.png*
-rwxrwxrwx 1 arnaud arnaud 344 août  19 18:46 list-bullet.png*
-rwxrwxrwx 1 arnaud arnaud 357 août  19 18:46 list-numeric.png*
-rwxrwxrwx 1 arnaud arnaud 606 août  19 18:46 picture.png*
-rwxrwxrwx 1 arnaud arnaud 537 août  19 18:46 preview.png*
-rwxrwxrwx 1 arnaud arnaud 743 août  19 18:46 quotes.png*

static/markitup/sets/restructuredtext:
total 12K
drwxrwxrwx 2 arnaud arnaud 4,0K août  19 18:46 images/
-rwxrwxrwx 1 arnaud arnaud 2,8K août  19 18:46 set.js*
-rwxrwxrwx 1 arnaud arnaud 1,2K août  19 18:46 style.css*

static/markitup/sets/restructuredtext/images:
total 64K
-rwxrwxrwx 1 arnaud arnaud  304 août  19 18:46 bold.png*
-rwxrwxrwx 1 arnaud arnaud 1,1K août  19 18:46 close.png*
-rwxrwxrwx 1 arnaud arnaud  859 août  19 18:46 code.png*
-rwxrwxrwx 1 arnaud arnaud  276 août  19 18:46 h1.png*
-rwxrwxrwx 1 arnaud arnaud  304 août  19 18:46 h2.png*
-rwxrwxrwx 1 arnaud arnaud  306 août  19 18:46 h3.png*
-rwxrwxrwx 1 arnaud arnaud  293 août  19 18:46 h4.png*
-rwxrwxrwx 1 arnaud arnaud  304 août  19 18:46 h5.png*
-rwxrwxrwx 1 arnaud arnaud  310 août  19 18:46 h6.png*
-rwxrwxrwx 1 arnaud arnaud  223 août  19 18:46 italic.png*
-rwxrwxrwx 1 arnaud arnaud  343 août  19 18:46 link.png*
-rwxrwxrwx 1 arnaud arnaud  344 août  19 18:46 list-bullet.png*
-rwxrwxrwx 1 arnaud arnaud  357 août  19 18:46 list-numeric.png*
-rwxrwxrwx 1 arnaud arnaud  606 août  19 18:46 picture.png*
-rwxrwxrwx 1 arnaud arnaud  537 août  19 18:46 preview.png*
-rwxrwxrwx 1 arnaud arnaud  743 août  19 18:46 quotes.png*

static/markitup/sets/textile:
total 16K
drwxrwxrwx 2 arnaud arnaud 4,0K août  19 18:46 images/
-rwxrwxrwx 1 arnaud arnaud  333 août  19 18:46 readme.txt*
-rwxrwxrwx 1 arnaud arnaud 2,2K août  19 18:46 set.js*
-rwxrwxrwx 1 arnaud arnaud 1,5K août  19 18:46 style.css*

static/markitup/sets/textile/images:
total 68K
-rwxrwxrwx 1 arnaud arnaud 304 août  19 18:46 bold.png*
-rwxrwxrwx 1 arnaud arnaud 859 août  19 18:46 code.png*
-rwxrwxrwx 1 arnaud arnaud 276 août  19 18:46 h1.png*
-rwxrwxrwx 1 arnaud arnaud 304 août  19 18:46 h2.png*
-rwxrwxrwx 1 arnaud arnaud 306 août  19 18:46 h3.png*
-rwxrwxrwx 1 arnaud arnaud 293 août  19 18:46 h4.png*
-rwxrwxrwx 1 arnaud arnaud 304 août  19 18:46 h5.png*
-rwxrwxrwx 1 arnaud arnaud 310 août  19 18:46 h6.png*
-rwxrwxrwx 1 arnaud arnaud 223 août  19 18:46 italic.png*
-rwxrwxrwx 1 arnaud arnaud 343 août  19 18:46 link.png*
-rwxrwxrwx 1 arnaud arnaud 344 août  19 18:46 list-bullet.png*
-rwxrwxrwx 1 arnaud arnaud 357 août  19 18:46 list-numeric.png*
-rwxrwxrwx 1 arnaud arnaud 361 août  19 18:46 paragraph.png*
-rwxrwxrwx 1 arnaud arnaud 606 août  19 18:46 picture.png*
-rwxrwxrwx 1 arnaud arnaud 537 août  19 18:46 preview.png*
-rwxrwxrwx 1 arnaud arnaud 743 août  19 18:46 quotes.png*
-rwxrwxrwx 1 arnaud arnaud 269 août  19 18:46 stroke.png*

static/markitup/skins:
total 8,0K
drwxrwxrwx 3 arnaud arnaud 4,0K août  19 18:46 markitup/
drwxrwxrwx 3 arnaud arnaud 4,0K août  19 18:46 simple/

static/markitup/skins/markitup:
total 8,0K
drwxrwxrwx 2 arnaud arnaud 4,0K août  19 18:46 images/
-rwxrwxrwx 1 arnaud arnaud 3,3K août  19 18:46 style.css*

static/markitup/skins/markitup/images:
total 100K
-rwxrwxrwx 1 arnaud arnaud  28K août  19 18:46 bg-container.png*
-rwxrwxrwx 1 arnaud arnaud 1,7K août  19 18:46 bg-editor-bbcode.png*
-rwxrwxrwx 1 arnaud arnaud 1,7K août  19 18:46 bg-editor-dotclear.png*
-rwxrwxrwx 1 arnaud arnaud 1,5K août  19 18:46 bg-editor-html.png*
-rwxrwxrwx 1 arnaud arnaud 1,5K août  19 18:46 bg-editor-json.png*
-rwxrwxrwx 1 arnaud arnaud 1,8K août  19 18:46 bg-editor-markdown.png*
-rwxrwxrwx 1 arnaud arnaud 1,8K août  19 18:46 bg-editor.png*
-rwxrwxrwx 1 arnaud arnaud 1,7K août  19 18:46 bg-editor-textile.png*
-rwxrwxrwx 1 arnaud arnaud 1,5K août  19 18:46 bg-editor-wiki.png*
-rwxrwxrwx 1 arnaud arnaud 1,5K août  19 18:46 bg-editor-xml.png*
-rwxrwxrwx 1 arnaud arnaud  258 août  19 18:46 handle.png*
-rwxrwxrwx 1 arnaud arnaud  27K août  19 18:46 menu.png*
-rwxrwxrwx 1 arnaud arnaud  240 août  19 18:46 submenu.png*

static/markitup/skins/simple:
total 8,0K
drwxrwxrwx 2 arnaud arnaud 4,0K août  19 18:46 images/
-rwxrwxrwx 1 arnaud arnaud 2,5K août  19 18:46 style.css*

static/markitup/skins/simple/images:
total 36K
-rwxrwxrwx 1 arnaud arnaud 258 août  19 18:46 handle.png*
-rwxrwxrwx 1 arnaud arnaud 27K août  19 18:46 menu.png*
-rwxrwxrwx 1 arnaud arnaud 240 août  19 18:46 submenu.png*

static/markitup/templates:
total 8,0K
-rwxrwxrwx 1 arnaud arnaud 113 août  19 18:46 preview.css*
-rwxrwxrwx 1 arnaud arnaud 406 août  19 18:46 preview.html*

Comme annoncé, des droits foireux à 777, mais c'est juste pour la phase de développement.

Xavier Ordoquy a écrit :

Donc, tu remplaces ton STATIC_ROOT par STATICFILES_DIRS et ça devrait marcher

Merci pour les explications, c'est une nuance qui m'a échappée dans la doc. J'ai bien effectué le remplacement, puis utilisé la méthode collectstatic ( qui n'a récupéré que les fichiers pour admin ), et c'est toujours le même résultat : du 404 pour markitup et tout va bien pour django-admin.

La version de django utilisée est 1.4.1-1 sous debian sid, et le paquet django-markitup a été installé via easy_install.

Hors ligne

#5 20-08-2012 21:49:57

David Thenon
Membre
Inscription : 11-08-2010
Messages : 156
Site Web

Re : [Résolu] Markitup : problème de chemins static

Salut,

Si collectstatic ne récupère pas les fichiers de markitup c'est que Django n'en
a pas connaissance. Donc si tu utilises django-markitup, évidemment il faut
qu'il soit renseigné dans ton settings.INSTALLED_APPS pour que django ailler
"fouiner" dans son répertoire des statics.

Si tu a essayé d'intégrer markitup directement, alors il suffit juste d'ajouter
le chemin de ta copie de markitup dans settings.STATICFILES_DIRS et Django
pourra alors le retrouver.

Attention, STATIC_ROOT n'est pas le répertoire qui __diffuse__ les fichiers
statiques, c'est uniquement un rép

> [quote=Xavier Ordoquy]Donc, tu remplaces ton STATIC_ROOT par
> STATICFILES_DIRS et ça devrait marcher[/quote]

Il y a du avoir incompréhension je pense, STATIC_ROOT doit être rempli
correctement et ce que tu avais fait initialement semble correct :

> STATIC_ROOT = '/home/arnaud/site/static/'

Ca c'est bien, c'est le répertoire où seront mis les fichiers static collectés
(par collectstatic ou le loader en mode de développement)

À la base tu ne dois rien y mettre, c'est django qui doit le remplir
(virtuellement par le loader en mode DEBUG, ou pour de vrai avec
collectstatic).

Donc tu déplace ton markitup qui était "/home/arnaud/site/static/markitup",
ailleurs, ou tu veux puis tu renseigne son nouveau chemin :

STATICFILES_DIRS = ('/monchemin/vers/ma/copie/de/markitup',)

Une fois fait tu lances collectstatic juste pour voir ce qu'il peut scanner
(pas la peine de créer les statics en mode debug). En théorie il devrait
parcourir tes statics de markitup.

Hors ligne

#6 20-08-2012 22:14:21

Arnaud
Membre
Inscription : 16-06-2012
Messages : 14

Re : [Résolu] Markitup : problème de chemins static

David Thenon a écrit :

Si collectstatic ne récupère pas les fichiers de markitup c'est que Django n'en
a pas connaissance. Donc si tu utilises django-markitup, évidemment il faut
qu'il soit renseigné dans ton settings.INSTALLED_APPS pour que django ailler
"fouiner" dans son répertoire des statics.

J'allais répondre qu'évidemment c'était le cas, jusqu'à ce que je prenne la couleur rouge cramoisie devant mon écran.
Non seulement je vous dérange pour rien, mais en plus je me suis retapé la doc sur les fichiers static/media ce soir avec prise de tête idiote depuis quelques jours.

Bref, je suis désolé de vous avoir embêté pour rien, et je crois que j'ai besoin d'une pause smile
Et merci pour les réponses.

Hors ligne

#7 20-08-2012 22:20:29

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

Re : [Résolu] Markitup : problème de chemins static

N'hésite pas à passer sur irc, channel django-fr. L'interaction sera plus rapide que par mails wink

Xavier Ordoquy,
Linovia.

Hors ligne

Pied de page des forums