Wednesday, October 30, 2013

Re: 1.5.4 /static/ serving 500 error

Hi Mike,
Thank you for the answer. You're right about the directory
structuring, and quoting the BDFL's "Better Explicit than Implicit".

For future reference(and list archive), the solution is this:

Remove (STATIC_ROOT,) from this line:

STATICFILES_DIRS = (STATIC_ROOT,)


The root directory for static files cannot also be a directory Django
searches for static files in. Running manage.py collectstatic returns
"ImproperlyConfigured: The STATICFILES_DIRS setting should not contain
the STATIC_ROOT setting"

The above code is still live on tangowithdjango at
(http://www.tangowithdjango.com/book/chapters/templates_static.html#serving-static-media)

I believe tangowithdjango is written for 1.5.4, so I'll follow up with
them as well. (Are they on this list)?

Best,
Thomas



On Thu, Oct 24, 2013 at 4:56 PM, Mike Dewhirst <miked@dewhirst.com.au> wrote:
> 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+unsubscribe@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+unsubscribe@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.



--
Sincerely,
Thomas Murphy
Code Ninja
646.957.6115

--
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+unsubscribe@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/CAEcwjczY0oRmCdXs_GfKk%2BQUW5mhrKDon8FCZ0iFk7f_fxgt2A%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment