# Django 404 errors

 0 If you experience strange 404 errors with Django apps, read the following. First, check the logs (either with "dotcloud logs", or with "dotcloud ssh" and then fiddle around). Start with the nginx logs, in /var/log/nginx/.....error.log. If you see the following: [error] 62#0: *86 upstream prematurely closed connection while reading response header from upstream, client: 10.254.99.244, server: [...], request: "GET / HTTP/1.0", upstream: "uwsgi://unix:///var/dotcloud/uwsgi.sock:", host: "[...].dotcloud.com", referrer: "[...]"; [error] 62#0: *86 open() "/home/dotcloud/current/static/502.html" failed (2: No such file or directory), client: [...], server: [...], request: "GET / HTTP/1.0", upstream: "uwsgi://unix:///var/dotcloud/uwsgi.sock:", host: "[...].dotcloud.com", referrer: "[...]"; It means that the 404 error is actually a 502 error (but if no 502 error page is defined, it ends up with the 404). 502 means problem with WSGI. So let's see the uwsgi logs; you will probably find a huge traceback, but it boils down to an ImportError: [...]  "No module named xxx" That's because only the "current" directory is in the PYTHONPATH; not the directory which contains your app and other modules (let's say it's "myapp", so you have /home/dotcloud/current/myapp.manage.py). We have (at least) the following solutions here: Change all the code to replace module imports and prepend "myapp" in front of them (not very convenient). Tweak wsgi.py to add "import sys ; sys.path.append('/home/dotcloud/current/myapp')". Ttweak the module loader, for example like this: "echo /home/dotcloud/current/myapp > /home/dotcloud/env/lib/python2.6/site-packages/myapp.pth".   Of course, you have to restart the service after that, to pick up the new PYTHONPATH ("dotcloud restart myapp.www"). asked Sep 06 '11 jpetazzo 363 ● 2 ● 3 ● 7

 0 I got this Django 404 errors with same logs but none of the solution above solved this issue. I noticed that the apps that I created with Django dev version (1.4.X) would give me this error (Django 1.3.1 is used on Dotcloud). After replacing the 1.4 dev version with the 1.3.1 on my dev machine, the app created with 1.3.1 would not give me this error and would work properly. I don't know the underlying reason behind it but at least it solved the issue => check Django version on your development machine. answered Oct 13 '11 jeanbaptiste 1 ● 2
 0 The new and updated Django tutorial is here: http://docs.dotcloud.com/tutorials/python/django/ It will answer your question regarding admin media :-) answered Sep 06 '11 jpetazzo 363 ● 2 ● 3 ● 7
 0 I'm currently working on a new and improved version of the Django tutorial. I hope it will help to clear up this issue! :-) answered Aug 30 '11 jpetazzo 363 ● 2 ● 3 ● 7
 0 @vivek: looks like I'm late, you already solved your problem — didn't you? (http://e3896987.dotcloud.com/static/admin/css/dashboard.css loads alright now) answered Aug 25 '11 jpetazzo 363 ● 2 ● 3 ● 7
 0 @anonymous : patience @Jérôme : I have my django static files are in " root/static/  " but still get 404 error, like this : ==> /var/log/nginx/djangomongo-default-www-0.error.log <==2011/08/25 17:20:33 [error] 3050#0: *4 open() "/home/dotcloud/current/static/admin/css/dashboard.css" failed (2: No such file or directory), client: 10.68.47.216, server: djangomongo-default-www-0, request: "GET /static/admin/css/dashboard.css HTTP/1.0", host: "e3896987.dotcloud.com", referrer: "http://e3896987.dotcloud.com/admin/" I know my file is there in "/home/dotcloud/current/static/admin/css/dashboard.css"Any guess where I might be going wrong ? My app is here : http://e3896987.dotcloud.com/ answered Aug 25 '11 suho 1 ● 1 ● 1
 0 That's strange.Ealier :1> I had deleted the "django" folder from "/home/dotcloud/env/lib/python2.6/site-packages/" , in order for python to use the one in my application directory.2> After I did that I could access by admin page but without any static files. Now :1> Now the Django folder seems to be back in site-packages/  and I cant access the admin page2>Static files are working fine. :P answered Aug 26 '11 suho 1 ● 1 ● 1
 0 @anonymous, the Python service allows to deploy Django with minimal effort. Unfortunately, there is still some work to do, but we strive to minimize the boring sysadmin part. Your app just has to follow some conventions. Now, please, if you have questions not related to "Django 404 errors" (the topic you posted to), feel free to ask them again by opening a different topic. That's a basic principle in online forums: don't hijack a topic by polluting it with questions irrelevant to to current subject. We always answer to criticism and negative feedback, so don't worry, your complaints will be addressed — I will make sure that they are, and we will do our best to help you reconsider your first experience with DotCloud. answered Aug 08 '11 jpetazzo 363 ● 2 ● 3 ● 7
 0 Well anonymous, when you use django you have to have SOME knowledge of python. Dotcloud is 10x easier than trying to set up WSGI for a newbie on a personal server... (trust me, I've tried). And plus, they have an AMAZING free plan, so why you complaining? answered Aug 07 '11 puzzler995 1
 0 I invite you to open new topics on the forum related to those questions; and I promise that we will answer them, don't worry! answered Aug 08 '11 jpetazzo 363 ● 2 ● 3 ● 7