Skip to content

pa_autoconfigure_django.py adds MEDIA_ROOT to settings.py disturbing clean git state on PythonAnywhere #1863

@Oktosha

Description

@Oktosha

When I went through the tutorial on the Deploy! step I noticed that the following diff was added to settings.py after running pa_autoconfigure_django.py

+
+MEDIA_URL = '/media/'
+MEDIA_ROOT = Path(BASE_DIR / 'media')

This change isn't conflicting with any changes later in the tutorial so when I did git pull later everything just worked. If you never run git status in the PythonAnywhere console you might even not notice it is there.

However this change might cause problems for someone who want to change settings.py later. And I don't know what is the best way to address this unclean state of git so I can't come up with a pull request that would solve this issue. Possible solutions I see

  1. Add MEDIA_URL and MEDIA_ROOT to the initial settings.py so that the script wouldn't need to add them (but why would we add the settings we don't need?)
  2. Suggest running git checkout -- . after pa_autoconfigure_django.py and then suggesting an option to add the MEDIA_URL and MEDIA_ROOT lines back through the flow "my machine -> GitHub -> pythonanywhere"
  3. Setting up pushing ability from pythonanywhere and commiting the change through the pythonanywhere console and pushing it to GitHub. One way to do it would be creating an ssh "deploy key" for the repository and adding it to pythonanywhere. Adding an ssh key to pythonanywhere is super easy. Could be a great practice if we switch to ssh auth to GitHub from the local machines, too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions