Just my blog
Blog about everything, mostly about tech stuff I made. Here is the list of stuff I'm using at my blog. Feel free to ask me about implementations.
- Mobaxterm SSH RDP FTP...
- Thunderbird Email client
- Filezilla FTP client/server
- Nirsoft Win utils
- Sysinternals Win utils
- Pi-Hole AD block by DNS
- NUT UPS manager
- Rpi MON Raspberry monitoring
- Free CAD 3D modelling
- Free Commander Far-like filemanager
- Bitwarden Password manager
- Django web framework
- celery multi-tasking
- celery-beat Celery + Django
- celery-results Celery + Django
- Pillow Python image lib
- wsgi mod Apache + Python
- requests best in WEB requests
- openpyxl make Excell docs
- p4python Perforce + Python
- paramiko SSH + Python
- pyvmomi ESXi Vcenter + Python
I'm using these libraries so you can ask me about them.
Gjango, Pycharm - static files Windows
This topic for those who broke his mind trying to understand how to make Pycharm run Django with static files I've made it, but be carefull it can break your mind too!
The settings
I use the most portable way to configure settings - so I can move it into centos web server without paths changes Win\Unix (I HOPE). There are common DIRs
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # BASE DIR: D:\Projects\CODE\WEB\sites\www\smm_tools\smm_site
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__)) # PROJECT_ROOT: D:\Projects\CODE\WEB\sites\www\smm_tools\smm_site\main_code
STATIC_ROOT = os.path.join(BASE_DIR, 'static') #Static root: D:\Projects\CODE\WEB\sites\www\smm_tools\smm_site\static
STATIC_URL = '/static/'
Looks like ot works, but in really weird way:
- static files are working fine
- web page as template is loading
- some scc and js are loading and some are not
Working css:
In works in different ways - this is one of them which I think correct.
In HTML code:
<link href="{% static 'css/bootstrap.css' %}" rel="stylesheet" type="text/css"> <link href="{% static 'css/custom.css' %}" rel="stylesheet" type="text/css">
In WEB:
Working js:
The weird stuff happened:
In HTML:
<script src="{{ STATIC_URL }}js/jquery-1.11.2.min.js" type="text/javascript"></script> <script src="{{ STATIC_URL }}js/bootstrap.js" type="text/javascript"></script>
In WEB:
Loaded: But: So in both situations static files ARE loaded but with different variables in HTML code and some was unsuccessful. There are ALL other situations which SHOULD work in different condtitions BUT it doesn't!
Not Working:
In HTML:
{#<link href="{% static 'css/bootstrap.css' %}" rel="stylesheet" type="text/css">#} {#<link href="{% static 'css/custom.css' %}" rel="stylesheet" type="text/css">#} {#Commented lines which work last time.#} <!-- It doesn't work GET http://127.0.0.1:8000/static/custom.css GET http://127.0.0.1:8000/static/bootstrap.css --> {#Those can work IF STATICFILES_DIR has os.path.join(BASE_DIR, '/static/css/'),#} <link href="{% static 'bootstrap.css' %}" rel="stylesheet" type="text/css"> <link href="{% static 'custom.css' %}" rel="stylesheet" type="text/css"> <!-- It loads but with error: Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://127.0.0.1:8000/date/css/bootstrap.css". Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://127.0.0.1:8000/date/css/custom.css". --> <link href="{{ STATIC_URL }}css/bootstrap.css" rel="stylesheet" type="text/css"> <link href="{{ STATIC_URL }}css/custom.css" rel="stylesheet" type="text/css"> <!-- It loads but with error: Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://127.0.0.1:8000/date/bootstrap.css". Resource interpreted as Stylesheet but transferred with MIME type text/html: "http://127.0.0.1:8000/date/custom.css". --> {#Those can work IF STATICFILES_DIR has os.path.join(BASE_DIR, '/static/css/'),#} <link href="{{ STATIC_URL }}bootstrap.css" rel="stylesheet" type="text/css"> <link href="{{ STATIC_URL }}custom.css" rel="stylesheet" type="text/css">
In WEB: Static JS have different situation: In HTML:
<!-- 404: GET http://127.0.0.1:8000/static/js/jquery-1.11.2.min.js GET http://127.0.0.1:8000/static/js/bootstrap.js GET http://127.0.0.1:8000/static/js/jquery-1.11.2.min.js GET http://127.0.0.1:8000/static/js/bootstrap.js --> <script src="{% static 'js/jquery-1.11.2.min.js' %}" type="text/javascript"></script> <script src="{% static 'js/bootstrap.js' %}" type="text/javascript"></script> <!-- 404: GET http://127.0.0.1:8000/static/jquery-1.11.2.min.js GET http://127.0.0.1:8000/static/bootstrap.js GET http://127.0.0.1:8000/static/jquery-1.11.2.min.js GET http://127.0.0.1:8000/static/bootstrap.js --> {#Those can work IF STATICFILES_DIR has os.path.join(BASE_DIR, '/static/js/'),#} <script src="{% static 'jquery-1.11.2.min.js' %}" type="text/javascript"></script> <script src="{% static 'bootstrap.js' %}" type="text/javascript"></script> <!-- Uncaught SyntaxError: Unexpected token < bootstrap.js:2 Uncaught SyntaxError: Unexpected token < --> <script src="{{ STATIC_URL }}js/jquery-1.11.2.min.js" type="text/javascript"></script> <script src="{{ STATIC_URL }}js/bootstrap.js" type="text/javascript"></script> <!-- Uncaught SyntaxError: Unexpected token < bootstrap.js:2 Uncaught SyntaxError: Unexpected token < --> {#Those can work IF STATICFILES_DIR has os.path.join(BASE_DIR, '/static/js/'),#} <script src="{{ STATIC_URL }}jquery-1.11.2.min.js" type="text/javascript"></script> <script src="{{ STATIC_URL }}bootstrap.js" type="text/javascript"></script>
Trying everything but still no luck.