On 25/10/2013 6:14am, Thomas Murphy wrote:
Hi all,

with structure

|myproject
|---static
|    ---picture.jpg
|--myproject
     ---settings.py


This could be improved in the sense that Django projects usually consist of one or more apps - like this ...

|myproject
|---static
|      (empty until you run manage.py collectstatic)
|---myproject
|      settings.py
|---myapp_1
|      models.py
|   ---static
|         myapp_1_picture.jpg



settings.py
import os
MYPROJECT_PATH = os.getcwd()

I don't think this is explicit enough. You need to be certain that the directories are exact in relation to settings.py. This is slightly more explicit ...

SETTINGS_FILE = os.path.realpath(os.path.dirname(__file__))
SETTINGS_DIR = os.path.split(SETTINGS_FILE)[0]
PROJECT_DIR = os.path.split(SETTINGS_DIR)[0]

There are a few different ways to do this in Python but this is the way I first got it to work and I haven't bothered to improve it.


DEBUG = True

***

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

This is where collectstatic puts all the files you cleverly organise into your various STATICFILES_DIRS directories.


STATIC_URL = '/static/'

STATICFILES_DIRS = (STATIC_ROOT,)

Instead of this, you need a myproject/myapp_1/static for pictures etc

STATICFILES_DIRS = (os.path.join(PROJECT_DIR, 'myapp_1', 'static'),)

Good luck

Mike


in Django 1.5.4

I am receiving a 500 error in terminal and the "A server error
occurred. Please contact the administrator." text on the page.

I've sorted through the relevant Django docs, SO answers, and list
archives, but I don't seem to find an identical circumstance to this.
Anything jump out to anyone? Gratitude.

--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/4d16cd13-039b-4250-9599-12aa0aaf8384%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/52698970.2040809%40dewhirst.com.au.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to