django


Deploy a Django Site with another folder for static files


My enviroment is with Django 1.10.7, PostgreSQL 9.4 and Nginx 1.6 with Gunicorn
I have a global folder called static for common static files to use in sub apps, then i set another folder for production mode with the name 'static_root':
in my settings.py
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static_root')
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static")
]
in my urls.py:
from django.conf import settings
from django.conf.urls.static import static
if settings.DEBUG:
urlpatterns += (static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT))
urlpatterns += (static(settings.STATIC_URL, document_root=settings.STATIC_ROOT))
when debug is true all work perfect, but in production mode the site not see the static files
i set the location in nginx configuration too
thank!
i found the answer to my question,
the problem was that i set in the nginx configuration: root
location /static {
root /var/projects/project/static_root;
}
the correct way is: alias
location /static {
alias /var/projects/project/static_root;
}

Related Links

python 3 and django-python3-ldap - user can't login
Serialize with PK and deserialize with field data in django-rest-framework
Django model and forms for questionnaire app
Need Assistane in converting django model admin save method to Django Rest Framework
jquery chosen not showing dropdown in django admin
Use of multi-select field linked to other table
ValidationError raises when updating
Django : ModelForm with conditions
Trying to access Django REST API in Angular2
Isn't foreign key to contenttype sufficient?
Adding custom parameter to django modelform
Django staff user can't see any application
Pass custom context to Django model
Django Forbidden (CSRF cookie not set.)
File uploading from Poco client to Django server
Django response nested models

Categories

HOME
shell
porting
awk
jmeter
twig
battery
sitecore
spring-data-redis
pclxl
x264
bing-maps
pattern-matching
java.util.logging
rtf
libc
mongodb-csharp
html5-appcache
solrcloud
cgbitmapcontext
dpdk
pimcore
php-mysqlidb
event-store
dynamically-generated
google-api-client
slidetoggle
stackexchange
corpus
handler
winexe
tpm
sqsh
google-earth
scrollview
fstream
card.io
pop3
nested-lists
wurfl
dm-script
connection-pool
css-position
opensmpp
setup.py
apache-stanbol
numberpicker
plaintext
placeholder
procfile
clarifai
magic-draw
video-conferencing
subnet
ngmaterial
cd-burning
stax
centrifuge
segment-io
dotnetnuke-7
wso2developerstudio
nservicebus5
deep
query-by-example
mobiledoc-kit
jbase
dynatree
computer-architecture
coda
linked-tables
mirror
ms-access-2000
user-permissions
fits
cryptographichashfunction
ssis-data-flow
post-commit-hook
build-script
codeplex
lnk
dot42
android-framework
koala
android-audiorecord
mysql-error-1044
script#
poker
wp7test
zope.interface
apache-whirr
screen-size
matlab-load
exponentiation
webdev.webserver
burndowncharts
escrow
fault-tolerance
wspbuilder

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App