django-staticfiles

Django: External JS using framework doesn't load

霸气de小男生 提交于 2020-07-11 03:25:29
问题 I have these JS files that runs just fine on local host server using WAMP Server. However when I put these files into my templates in Django then nothing loads. index.html template {% load staticfiles %} <!doctype html> <html lang="en"> <head> <meta charset="UTF-8" /> <title>Phaser - Making your first game, part 1</title> <script type="text/javascript" src="{% static 'game/js/game.js' %}"></script> </head> <body> And this is game.js (using Phaser.io framework) var game = new Phaser.Game(1000,

Django : static files are not loaded

三世轮回 提交于 2020-07-10 07:21:25
问题 i'm trying to test the code mentionned in this page : dynamic-formset.js and i added : <script src="{% static 'js/dynamic-formset.js' %}"></script> <script src="{% static 'js/jquery-3.3.1.js' %}"></script> in order to load static files that contains js. howerver the js doesn't work and i'm getting in the console the following lines : "GET /static/js/dynamic-formset.js HTTP/1.1" 404 1777 "GET /static/js/jquery-3.3.1.js HTTP/1.1" 404 1768 when i replace the second ligne that imports jquery with

problem in loading media files into templates

巧了我就是萌 提交于 2020-07-10 07:07:31
问题 My django project is searching for images in /profile/<pk>/myapp/profile_pics/images.jpg instead of myapp/profile_pics/images.jpg similar to this question image isn't uploaded to media root using Django settings.py - MEDIA_ROOT = os.path.join(BASE_DIR, 'media') MEDIA_URL = '/media/' urls.py - urlpatterns = [ path('profile/<int:pk>/', views.profile, name='profile'), ] if settings.DEBUG: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) views.py - def profile(request,

Django. Listing files from a static folder

て烟熏妆下的殇ゞ 提交于 2020-07-06 20:35:28
问题 One seemingly basic thing that I'm having trouble with is rendering a simple list of static files (say the contents of a single repository directory on my server) as a list of links. Whether this is secure or not is another question, but suppose I want to do it... That's how my working directory looks like. And i want to list all the files fro analytics folder in my template, as links. I have tried accessing static files in view.py following some tutorial and having it like that: view.py from

What's the difference between STATIC_URL and STATIC_ROOT in Django?

点点圈 提交于 2020-06-09 11:59:08
问题 I'm somewhat confused as to what the difference is between STATIC_URL and STATIC_ROOT in Django's 'staticfiles' app. I believe I understand what the STATIC_ROOT is: it's essentially the location on the server where the staticfiles' collectstatic command will place the static files collected from your django project. The collectstatic command searches in the locations that you specify in the STATIC_FINDERS setting. However, what exactly does the STATIC_URL do? What should this be set to?

Serve Static files from Google Cloud Storage Bucket (for Django App hosted on GCE)

最后都变了- 提交于 2020-05-28 06:35:58
问题 I am trying to serve the static Files for my django App from Cloud Storage Bucket but don't know the exact process. Can someone please suggest a proper way to do so ? Steps I did: Uploaded all the static files on Google Cloud Storage Bucket(www.example.com) using gsutil command. Edited /etc/apache2/sites-available/default-ssl.conf File. File Content: <VirtualHost *:443> ServerName example.com ServerAdmin admin@example.com # Alias /static /opt/projects/example-google/example_static Alias

Serve Static files from Google Cloud Storage Bucket (for Django App hosted on GCE)

只谈情不闲聊 提交于 2020-05-28 06:34:13
问题 I am trying to serve the static Files for my django App from Cloud Storage Bucket but don't know the exact process. Can someone please suggest a proper way to do so ? Steps I did: Uploaded all the static files on Google Cloud Storage Bucket(www.example.com) using gsutil command. Edited /etc/apache2/sites-available/default-ssl.conf File. File Content: <VirtualHost *:443> ServerName example.com ServerAdmin admin@example.com # Alias /static /opt/projects/example-google/example_static Alias

Serve Static files from Google Cloud Storage Bucket (for Django App hosted on GCE)

蹲街弑〆低调 提交于 2020-05-28 06:33:05
问题 I am trying to serve the static Files for my django App from Cloud Storage Bucket but don't know the exact process. Can someone please suggest a proper way to do so ? Steps I did: Uploaded all the static files on Google Cloud Storage Bucket(www.example.com) using gsutil command. Edited /etc/apache2/sites-available/default-ssl.conf File. File Content: <VirtualHost *:443> ServerName example.com ServerAdmin admin@example.com # Alias /static /opt/projects/example-google/example_static Alias

Load static files in Django Admin panel using Python in CPanel

偶尔善良 提交于 2020-05-28 06:07:30
问题 I have already set up a Django Python application in my server with CPanel. The wsgi is correctly configured, the index.html (which doesn't have any css) runs properly but the admin panel doesn't load correctly the css. I have been reading that I need to properly set the static files routes and none of this seems to work. My settings.py file have the static directive in the installed apps and this lines at the end, where my static files of the python virtualenv is. STATIC_URL = '/static/'

collecstatic does not push to files S3

不羁的心 提交于 2020-05-10 03:37:34
问题 EDIT: I have found that removing import django_heroku from my settings.py file allows me to push my static files to my AWS bucket. When I uncomment import django_heroku , collectstatic then pushes my files to the staticfiles folder. manage.py collectstatic with #import django_heroku : You have requested to collect static files at the destination location as specified in your settings. maange.py collectstatic with import django_heroku : You have requested to collect static files at the