11👍
Here is the key to solving the problem: Pycharm needs to know where your settings files that you’re currently using is located. See the picture.
Also make sure that you have everything setup in your settings file correctly. See the picture.
2👍
In some situation this way can work:
<link href="{{ STATIC_URL }}" rel="stylesheet" type="text/css">
1👍
If you have setup everything correctly according to Django doc at:
https://docs.djangoproject.com/en/3.1/howto/static-files/
Then you can try to explicitly set your static folders to help the IDE like:
STATICFILES_DIRS = (
BASE_DIR / "app1/static",
BASE_DIR / "app2/static",
)
this works for me many times. IntelliJ just could not automatically find my app’s static.
- Django REST Framework: define fields in nested object?
- Ignoring case with __startswith
- Django, Apache2 on Google Kubernetes Engine writing Opencensus Traces to Stackdriver Trace
- How to build a secure Django single signon between different sites?
- Localization: django-admin compilemessages skip venv
0👍
PyCharm recognises my static files for a configured settings.STATIC_ROOT
as below
STATIC_URL = '/assets/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
- Django N+1 query solution
- Django – Extending another apps ModelAdmin?
- Difficulty with Django and jQuery (why is $ undefined in the admin app?)
- Make Django forms use comma as decimal separator
0👍
Try loading your staticfiles:
{% load staticfiles %}
And setting your link as:
<link rel="stylesheet" type="text/css" href="{% static "css/default.css" %}">
- Check if a unique value exists before creating it
- Django – Import views from separate apps
- How do I get a "debug" variable in my Django template context?
0👍
I used:
-
STATIC_ROOT = os.path.join(BASE_DIR, "static_deployment")
-
python manage.py collectstatic
command
So I did what needs to be done to go from development to deployment configuration.
pyCharm now works fine and can see static files
Yes it is not the best solution if you change static files a lot but can help developing with pyCharm and Django…
- Issue with Django 2.0 : 'WSGIRequest' object has no attribute 'session'
- Different sessions for admin and applications in Django
- Django Limit ManytoMany queryset based on selected FK
- How to send file to response in Django?
-2👍
Check in settins.py
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'your_app/static/')
]
and add
STATIC_ROOT = os.path.join(BASE_DIR, '/static/')
Pycharm use this settings.