Deploying a Django project - WSGI problem

Hi there,

I’m having some hard time with deploying the website on python anywhere as part of ‘Build python web apps with Django course’. If visit the site it says “Something went wrong” and the error log looks like this:

What confuses me, is there is no module mysite and line 17 in WSGI is blank. I changed the mysite and yourname, i tried the debugg site, but its dead end (for me).

I used the djangovet files from github, and I think I followed the instructions in the course guide. Can anyone help please? :wink:

I’d double-check that, then, because it’s certainly looking for something with that name. Given it’s in the boilerplate repo provided, I wonder whether a save didn’t go through or something.

Hi, thanks for your reply. I went through the setting up again and discovered, that the site is functional until i paste the following code to from the codecademy course:

KEYSDIR = str(BASE_DIR)+"/keys.json" with open(KEYSDIR) as k: project_keys = json.loads( def getKey(setting,project_keys=project_keys): try: return project_keys[setting] except KeyError: errorMessage = "Set the {} env var".format(setting) raise ImproperlyConfigured(errorMessage)

After that, the site crashes with the problems I mentioned earlier. I figured, that the site may run even without this part of code - its about hiding the secretcode in keys.json and this code should call that key from json.

Can you please provide the contents of your WSGI file? This is the file which you’re asked to create/update in step 15, below:

Hi so I think I solved this, it worked for me anyways.
In the file, leave the imports for json and ImproperlyConfigured at the top of the page, but move all the code that you shared starting from "KEYSDIR = str(BASE_DIR)+‘/keys.json’ and ending with "raise ImproperlyConfigured(errorMessage). Move all of that right below the code that looks like this:

Build paths inside the project like this: BASE_DIR / ‘subdir’.

BASE_DIR = Path(file).resolve().parent.parent

Quick-start development settings - unsuitable for production

See Deployment checklist | Django documentation | Django

put all the code here. And as you figured out, just make sure that the ‘yourname’ and the two ‘mysite’ parts got changed. and make sure you save the file, and click the ‘reload’ button to make sure it’s saved.
We are having this problem because the lesson says to put the imports at the top of the page, but does not specify where to put the rest of the code, so I ended up putting the rest of the code above where the BASE_DIR gets defined.
after I did this, the web app worked for me. Hope this helps (:
here’s a screen shot.