Django in PythonAnywhere does not recognize static url

The problem is similar to the problem: Pythonanywhere, how to use static files? url? but I can not comment there.

I started learning Django, and when everything worked on localhost, that is not the case on PythonAnywhere.

In the project name /settings.py I set:

STATIC_ROOT = "/home/*username*/*projectname*/Static/"
STATIC_URL = "/s/"

and even URLs from static folders in applications.

After trying to start

python3 manage.py collectstatic

each * .js, * .css file and images were copied to the projectname / Static folder.

But ... not one of them was recognized after launching the application. I have installed

{% load static %}

tags

{% static "assets/css/theme.css" %}

In the source code, I see the correct link to the css file:

<script src="/s/assets/js/seen.min.js"></script>

, "/s/" django urls.py. : username.pythonanywhere.com/s/assets/js/seen.min.js , 404 urls.py.

?

+4
1

-. " " -.

, , "/s/" URL- "/home/* */* projectname */Static/" .

+5

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


All Articles