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

DatabaseError: no such table
django “no such table” when use ModelForm.save
Django Testing - check messages for a view that redirects
Tastypie Swagger with default configuration gives NoReverseMatch exception, says 'tastypie_swagger' is not a registered namespace
Django: Image Upload to the Server
'module' object is not callable Django
Django template - hide content based on time of day
Stored Procedure result to Django Model
django social auth with custom user model is not working
Django template - How do i iterate two dictionary at same time
Template Does not exist
URL template optional param
django templates: loop through list of classes/strings
is this a good use for django internationalisation
Programmatically downloading images and uploading them using ImageField via Boto
django admin readonly data (no edit, no add)

Categories

HOME
embedded
phantom-dsl
awk
eslint
pyqt
serialization
mstest
big-o
watson-conversation
plist
mod-security
openbugs
android-intent
screen-readers
searchview
asp.net-mvc-viewmodel
wolframalpha
html5-appcache
nim
visual-glitch
ksh
dpdk
r-mice
ios10.2
syntax-highlighting
jasmine-node
inversion-of-control
constexpr
cognos-bi
kodi
mailkit
github3.py
fossil
fiware-cygnus
salesforce-communities
lint
sessionstorage
tex
setup.py
laravel-elixir
parser-generator
softmax
oim
openal
serde
opengl-4
excel-dna
reshape
seq
lsyncd
rackspace-cloud
gameplay-kit
mathcad
shinobi
usart
preprocessor
uicolor
nikeplus-api
tooleap
gcloud-ruby
dbamp
cortex-m
vhosts
custom-errors
dynatree
dllimport
sapscript
dronekit-android
sha512
shopizer
rrule
gamekit
exceldatareader
filesplitting
cocos3d
entry-point
spring-remoting
clickbank
bin
printdialog
redis-py
jquery-blockui
oracle-enterprise-linux
uipagecontrol
http-daemon
nhprof
commerceserver2007
glui
scrubyt
fault-tolerance
application-planning

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