Django MAY find my static files, Pycharm CANNOT resolve them

I do not think this is a duplicate. I reviewed many answers to similar problems.

Note: This works fine, and django finds all the static files.

UPDATE: Sounds like a PyCharm bug. If I become static in the directory of my application, PyCharm will be able to solve it. But I have this static in the src main directory, because several applications will use CSS. It works now, and Django has no problem with this. I see that this is a PyCharm error.

PyCharm is set up, and everything else seems to work before the Pyjarm project offers the Django project.

Pycharm cannot decide, which means that I cannot use auto complete, and this is annoying. If I press ctrl-space, the only directory that appears is admin. This means that PyCharm completely ignores my static directory.

I also tried to make it a template and a consulting director. No luck there.

{% load static %} <!-- {% load staticfiles %} -->
...
<link rel="stylesheet" href="{% static ''%}">
<link rel="stylesheet" href="{% static 'css/skeleton.css' %}">
<link rel="stylesheet" href="{% static 'css/custom.css' %}">
...

This code works just fine. However, PyCharm does not find the URL.

INSTALLED_APPS = [
    'django.contrib.staticfiles',

    # admin specific
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.messages',
    'django.contrib.sessions',
]
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'static')
]

STATIC_URL = '/static/'

REBYgQhl.pngMFQXnzBl.png

+5
source share
6 answers

In some situations, this method may work:

<link href="{{ STATIC_URL }}" rel="stylesheet" type="text/css">

PyCharm static autocomplete

+2
source

PyCharm recognizes my static files for customized as shown below settings.STATIC_ROOT

STATIC_URL = '/assets/'

STATIC_ROOT = os.path.join(BASE_DIR, 'static')
0
source

:

{% load staticfiles %}

:

<link rel="stylesheet" type="text/css" href="{% static "css/default.css" %}">
0

: Pycharm , , . .

enter image description here

, . .

enter image description here

0

:

  1. STATIC_ROOT = os.path.join(BASE_DIR, "static_deployment")

  2. python manage.py collectstatic

, , .

pyCharm

, , , pyCharm Django...

0

STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'your_app/static/')
]

STATIC_ROOT = os.path.join(BASE_DIR, '/static/')

Pycharm .

0

Source: https://habr.com/ru/post/1669389/


All Articles