Multiple issues: ambiguous folder names, finding manage.py, and Heroku without dj-database-url

If I understand this lesson correctly, we are following a 'modular' layout, aka "The One True Way". In the last line of “Last System Wide Requirements”, Kenneth says we need to make a directory to hold our projects files, and he calls his “projects”. Now if you startproject inside this “projects” directory, the structure should look like this: projects/microblog/microblog. Following this model, manage.py is in the 1st microblog folder, and the second microblog folder is the app with settings in it. However, in the 2nd paragraph of “Diving Into Django”, Kenneth says manage.py is in the same “project” directory as Procfile. So… ONE Is “project” the same as “projects”, or does “project” refer to the folder created by startproject, which in this case would be the first, or outmost, microblog folder? TWO Because I understood him to be creating the projects/microblog/microblog structure, I have .gitignore, Procfile, and requirements.txt out there, in this outermost file. In other words, there is no manage.py here. THREE Although it ran fine locally, it has never come up on Heroku. The error message is that it can’t find manage.py. Now that makes sense if it is expecting manage.py to be in the first, or default, folder, which would be “projects”, but as I said, that’s not what I understood and not what I did. I did try changing the path in procfile, i.e.: python microblog/manage.py, but that didn’t work. I don’t know why. Apparently Procfile does not work as I expected, and I have yet to find an explanation of how it works with file paths. FOUR I did discover, however, that the present working directory on Heroku is not called “projects”, but “/apps”. Except for that, it lists the files I expected to be there. Putting /apps in my manage.py path still didn’t work. FIVE I see that dj-database-url is needed for Heroku, but in the next to last paragraph of “What Heroku does every time you push to them is”, Kenneth clearly expects us to be able to see “It worked” at this point, before he gets around to telling us to install dj-database-url. I have only gotten an application error at this point, and it is apparently not because I don’t have dj-database-url. So what is wrong? Or, if you can’t tell yet, what more do you need to know to help me? SIX In “File Paths in Django Settings”, Kenneth says: 'And so we set PROJECT_ROOT to be the directory above the settings file.' This only adds to my confusion, because this directory is what Django by default thinks of as the ‘app’ folder. The project directory, the one Django created with startproject, is above this. SEVEN Finally, if this is a two tier structure, what was the purpose of creating a “projects” folder in the first place? Can I just move .gitignore, Procfile, etc, to the outer, Django microblog folder, delete the outer projects folder, and re-commit to git without harm? Thank you very much.

Sorry You must be a logged in, registered user to answer a question.

Answers

OK, I'll try to answer as best I can.

  1. The "project directory" should be the outermost 'microblog' directory.
  2. Yes, manage.py, Procfile, and your .gitignore should be in the outermost microblog directory. We're not working in projects/, it's just a handy container for us.
  3. If there's not an __init__.py in the outermost microblog directory, Python would probably have path issues when you try and run the project from there.
  4. Yeah, the outermost directory name shouldn't matter.
  5. You can run the server both locally and on Heroku without a database, you just can't create users, log in, or create blog posts without one. You should be able to get everything running before you install dj-database-url. It might help you debug to run the line from your Procfile after you do heroku run /bin/bash.
  6. No, Django doesn't think of the innermost microblog directory as an app directory because it doesn't contain a models.py and isn't in INSTALLED_APPS. It just sees it as another Python module.
  7. I don't know about the moving and re-committing and I'm pretty sure git won't like that. You should be able to move files around, though, to get a working set up, and then commit the new locations. I wouldn't move my .git/ directory, though. That path likely leads to madness.