Hello, I installed my project on Windows server, but it cannot see the static files.
I tried many examples on the internet, but I could not solve the problem. please guide me on this
Settings.py
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, "/static/")
#STATICFILES_STORAGE = 'whitenoise.storage.CompressedStaticFilesStorage'
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
Urls.py
path('sitemap.xml', sitemap, {'sitemaps': sitemaps}, name='django.contrib.sitemaps.views.sitemap'),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) + static(settings.MEDIA_URL, document_root=settings.STATIC_ROOT)
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
python manage.py collectstatic This is the result I get when I do it:
You have requested to collect static files at the destination
location as specified in your settings:
C:\inetpub\vhosts\demo.com.tr\httpdocs\static
This will overwrite existing files!
Are you sure you want to do this?
Type ‘yes’ to continue, or ‘no’ to cancel: yes
0 static files copied to ‘C:\inetpub\vhosts\demo.com.tr\httpdocs\static’, 126 unmodified.
Are you using IIS as your web server?
Regardless of what web server you’re using, do you have it serving the /static/
path from C:\inetpub\vhosts\demo.com.tr\httpdocs\static
Yes, I use ISS. I didn’t fully understand your question. My English is bad.
You have:
STATIC_URL = '/static/'
This means that browsers accessing your site are going to try to retrieve static files with a URL that begins with /static/
.
You need to configure IIS so that any URL coming in that starts with /static/
will retrieve the files from C:\inetpub\vhosts\demo.com.tr\httpdocs\static
[quote=“KenWhitesell, post:5, topic:27973, full:true”]
You have:
STATIC_URL = '/static/'
This means that browsers accessing your site are going to try to retrieve static files with a URL that begins with /static/
.
You need to configure IIS so that any URL coming in that starts with /static/
will retrieve the files from C:\inetpub\vhosts\demo.com.tr\httpdocs\static
[/quoteYou need to configure IIS so that any URL coming in that starts with `/static/` will retrieve the files from `C:\inetpub\vhosts\demo.com.tr\httpdocs\staticI don’t have any information about what to do in ISP. Can you send a sample site or video?
I don’t have any information about what to do in IIS. Can you send a sample site or video?
I’m sorry, I haven’t seriously worked with IIS in about 18 years. The best I can do is refer you to the documentation at IIS documentation | Microsoft Learn You’re looking for whatever information is in there for configuring access to static content.