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

Django and Connector/Python Integration
many to many vs new object with compound foreign keys in django
Load Django “static” template tag library globally without explicitly loading it in every file
Django: template forloop multiple dictionaries
django how to create TemplateView instance with code
Can't disable select in ModelForm
facebook comments in django: url unreachable warning
How to convert django variable into json in template properly
Pass submitted form value to a new view
Can't install via pip because of egg_info error
django nginx configuration issue
Delete related models in django through a ManyToManyField
Django - TypeError on deserializing json from jQuery POST
ListView with Form in Django
Check if content_object is of certain model
django how to get Response in class based view

Categories

HOME
adal
formal-languages
3d
rsa
oracle-apex-5
sitecore
error-handling
grafana
limit
ado.net
jquery-ui-sortable
openstreetmap
siddhi
comsol
frequency-distribution
internationalization
firefox-addon
google-picker
git-extensions
digital-signature
rubymotion
inno-download-plugin
joptionpane
motion-detection
licensing
appirater
ceylon
bioinformatics
testcomplete
nsurl
gojs
keras-layer
yowsup
diacritics
doc
stringtokenizer
android-ibeacon
automapper-5
gitlist
wcftestclient
configurationmanager
tinymce-3
ngmaterial
seq
mouseleave
django-1.10
atlas
preprocessor
file-uri
uicolor
beamer
rspec2
freepbx
cassia
beanstalk
mobiledoc-kit
ascii-art
asyncdisplaykit
highland.js
android-launcher
sapscript
sony-lifelog-api
liquid-layout
skspritenode
aspectj-maven-plugin
android-cookiemanager
primitive-types
contrast
punycode
cbind
cancellation
qscrollarea
windows-embedded-standard
ice-cube
vfs
zope.interface
adobe-media-server
thttpd
koken
wiimote
entity-attribute-value
screen-size
strsep
socketserver
cac
delimited-text
silent
scrollbars
request-headers
sifr3
sqlobject

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App