The thing with STATIC Files | Deployment on PythonAnywhere

Hi Folks,

i’m done (for the moment) with my AppDevelopment and was thinking, that I should try it with deployment for further tests.

So I decided to test the migration to a “go_live” system by using the free offers of PythonAnywhere. After some struggeling with data upload and migrating the database, everything seemed fine. But in the end my App is reachable through the given URL of PythonAnywhere but is not displaying correctly. I’m pretty sure, that it is because of wrong dealing with static files…but where to start to give you a hint how to help me?

I’ve read the docs on this topic, I ran the collectstatic command, i specified the STATIC_URL in the Web_Tab of PythonAnywhere and in…what am I missing ?

Thx for any help (as always :slight_smile: )

I changed a single path to an image in one of the template files to the absolute path of the new collectstatic directory and then the image gets displayed without problems. So the thing seems to be that there is a problem in my file structure - I think.

so if my path-references in my project-templates are this way:

{% static 'app_name/images/favicon.png' %}

what do I have to Do/how to set up File-Structure correctly in PythonAnywhere to keep it running without editing each single static-reference in templates?

EDIT: With DEBUG: True everything works fine just like on testserver on my local machine…

Ok, after again reading some docs, i understood, that static-file handling is handed over to webserver with DEBUG: False. Additionally, I could solve my problem by realizing, that the defined static-paths in WEB-Tab on where one tree-level too deep :stuck_out_tongue:

So now everything is displayed properly. Only one thing left:

It seems I have to define the static-file path for everything concerning the Django-Admin-Panel seperately, because admin-panel is still displeayed as plain text. but which directory is the right one ?

Ok, never mind, now i got it :see_no_evil:

it is simply
URL: /static/
PATH: /home/(username)/(appname)/collectstatic

somehow, i first entered /collectstatic/ as URL, not realizing, that this is the template URL that has to be remapped…